You need to sign in to do that
Don't have an account?
Invalid Session ID with Curl
Hi.
I have an application (built in Ruby) that logs into my saleforce account and retrieves the token in the response. When I try and use this token with curl however I am always just getting the error that:
I have seen a couple of other posts that I have tried to revolve the problem with:
I definitely have the user set up with API access as per here
I also have an escaping character in the token which I am handling using a variable on my machine as per here
So my steps are:
I have a Ruby on Rails app that redirects me to salesforce and make me log in. The callback URL is then triggered which returns my token (with the escape character) like nnnnnnnnnnnnnnnn!nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
I store this token variable in my .bash_profile file as
export token=nnnnnnnnnnnnnnnn!nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
and if I run echo $token from the console it outputs the token correctly.
I then try and perform a curl command to the salesforce api constructed like:
curl https://na1.salesforce.com/services/data/v20.0/ -H "Authorisation: OAuth "$token -H "X-PrettyPrint:1"
You spelt Authorization wrong
Hi
Thanks for the reply. I still get the same error when I spell it your way.
Cheers
You're missing a quote after $token, it should be. if you use -v you can see more of the request/response which will help with diagnostics.
curl https://na11.salesforce.com/services/data/v20.0/ -H "Authorization: OAuth "$token" -H "X-PrettyPrint:1"
Also, depending on which format you're using for the oauth call, the token my be URL encoded, and need decoding before use.
I'm having a similar problem, how do you determine if the token is URL encoded? How would one decode it?
Thanks,
Michael
Solved my own problem, was a combination of escaping the "!" and using the write server.