I am trying to obtain enterprise WSDL by accessing https://cs15.salesforce.com/soap/wsdl.jsp?type=* URL via curl. For this, I have obtained access token through OAUTH2 method via the following curl command.

​curl https://cs15.salesforce.com/services/oauth2/token -d ‘grant_type=password -d client_id=myclientid -d client_secret=mysecret -d [email protected] -d password=mypassword

Next I used the access token in following curl command to obtain WSDL

curl https://cs15.salesforce.com/soap/wsdl.jsp?type=* -H "Cookie: sid=myaccesstoken"

But response from above curl command indicates that I was getting redirected to Salesforce login page instead of WSDL page.

  1. I have validated my approach by taking “sid” value from web browser cookies after successfully logging into Salesforce, used it in the above curl and it worked as I expected.
  2. I have also tried using the access token which I got through OAUTH2 method in REST API requests and they worked as expected. Hence I assume the access token via OAuth is valid.

Appreciate if someone can advise why I am not getting WSDL page or suggest me an alternate approach.

2 Answers 2


It looks like the problem could be that you were using an access token instead of a session id. I just got it to work by logging in through the enterprise api and using that session id for sid= in the header.

the command I used to log in and get the session id:

$ curl https://login.salesforce.com/services/Soap/c/33.0 -H 'Content-Type: text/xml; charset=UTF-8' -H 'SOAPAction: login' -d @login

the file login

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
        <n1:login xmlns:n1="urn:enterprise.soap.sforce.com">
  • Thanks for the suggestion and the example. I was able to successfully get session id and use it to get WSDL.
    – SSK
    Commented Aug 27, 2015 at 2:50

What OAuth scopes did you specify for your connected app? enter image description here

These should appear directly below the Consumer Key and Consumer Secret for the Connected App.

I suspect that without either the full or web scopes the Session Id won't be valid for what is essentially functionality that a web browser would perform. That the curl request works with a session id taken from the browsers sid cookie supports this.

Alternatively, you could use the credentials against either the Partner or Enterprise SOAP APIs to establish a full session.

  • Interesting idea. The sid= in the header makes me think that there is a possibility that there is a validation in place where the system will only accept a Session Id. It would be interesting to see if changing the scope of access provided by the Access Token would work here.
    – martin
    Commented Aug 26, 2015 at 8:46
  • @martin The access token and session id are fully interchangeable if the access token was created with the full scope. You'll notice that they have the same format. They will all appear under "Session Management" in the setup pages. Commented Aug 26, 2015 at 20:31
  • @DanielBallinger OAuth scope wasn't Full when I lodged my question. Nevertheless changing to Full access as you suggested did not solve the problem (though I was positive it would). For now I will settle with idea of obtaining session Id through SOAP API. Thanks for your suggestion.
    – SSK
    Commented Aug 27, 2015 at 2:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .