You need to sign in to do that
Don't have an account?

INVALID_SESSION_ID when downloading files from feeds
I am trying to download a file attached to a chatter feed. Barring extensions and other naming issues, there is an interesting problem:
I get a fresh OAuth access token from the stored refresh token, but every time I try to download the file I get a 401 response containing
[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]
Does anyone have had a similar issue? How can I unblock this? I have read the other messages regarding this but the proposed solutions (if any) do not work for me.
This is the command I use to download the file
curl -v https://na9.salesforce.com/services/data/v25.0/chatter/files/069E0000000UylDIAS/content -H "Authorization: OAuth xxDExxxxxxxxZCxx%21ARsAQGWxOZVEP.GemGLJ.PTYPGdVxcynRHBB9ExtYCxhgD1UJ6kFR_yVPqOofFZvLEmqxeXMtgXqBVxzvxGGqP_dAPxEvNlx"
(I've tried "Bearer" instead of "OAuth" in the auth header, as it's the word I use for the REST API, but the result is the same)
(some numbers and letters have been changed to "x" in the token, to protect it. It will expire in any case)
Thanks to everyone!
And I think the exclamation mark in Session Id that is escaped as "%21" may also be the case.
All Answers
Two suggestions:
1. The URL needs to be the last argument to curl, so reorder your command.
2. Use single quotes rather than " so that bash will not get hung up trying to interpret the header you're passing.
E.g.
curl -v -H 'Authorization: OAuth xxDExxxxxxxxZCxx%21ARsAQGWxOZVEP.GemGLJ.PTYPGdVxcy
nRHBB9ExtYCxhgD1UJ6kFR_yVPqOofFZvLEmqxeXMtgXqBVxzvxGGqP_dAPxEvNlx' https://na9.salesforce.com/services/data/v25.0/chatter/files/069E0000000UylDIAS/content
And I think the exclamation mark in Session Id that is escaped as "%21" may also be the case.
Thanks Thomas. The argument order is not a problem, but the single quotes in fact were (once the "!" was unescaped from the %21 I was passing).
Leon, the url-encoded exclamation mark was the problem! I was encoding the token to be able to be transported as part of a URL, and I didn't notice that it had escaped chars.
Thank you very much!