I am attempting to use curl (or any other viable alternative) to download a zip report from SalesForce, but I seem to be unable to do so. I am using syntax:

curl -o my_file.zip 'https://login.salesforce.com/?un=username&pw=password&ec=123&startURL=%2Fservlet%2Fservlet.OrgExport%3Fid%3Dfile_id%26fileName%3Dfile_name.ZIP'

If I navigate my browser in incognito to the url, I don't need to do anything further and the file begins to download. The curl command seems to do nothing, however.

I have also tried to store my cookies in a text file:

curl -c cookies.txt 'https://login.salesforce.com/?un=username&pw=password

and then passing in the cookies to my download url:

curl -b cookies.txt 'https://login.salesforce.com/?ec=123&startURL=%2Fservlet%2Fservlet.OrgExport%3Fid%3Dsample_id%26fileName%3Dsample_filename.ZIP'

Contents of cookies.txt:

.salesforce.com TRUE    /       FALSE   1234567890      BrowserId       sample_browser_id
.salesforce.com TRUE    /       FALSE   0       inst    APPj
.salesforce.com TRUE    /       TRUE    1234567890      login   username@email.com
.salesforce.com TRUE    /       FALSE   1234567890      com.salesforce.LocaleInfo       us
.salesforce.com TRUE    /       FALSE   1234567890      oinfo   sample_oinfo

1 Answer 1


That won't work, because login sends back a page that JavaScript redirects to the start URL, so curl will just see this html file and not know what to do with it. Instead, assuming you received a sid cookie from the first cookie command, your next step would be to call your instance server directly with the correct URL. This should allow the file to download as you expect.

  • Could you give an example of how I might call my instance server directly with the download URL? Would it be something like: curl -b cookies.txt 'https://instance_server.salesforce.com/servlet/servlet.OrgExport?fileName=sample_filename.ZIP&id=sample_id' Also, I've opdated the OP with sample details of what is inside my cookies.txt file. I don't see sid contained within.
    – raphnguyen
    Mar 20, 2015 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.