function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
konigswaggerkonigswagger 

Retrieve Attachment body

I am using OAuth and have been able to get a access_token (appended to the callback URL). Using the Force.com REST Toolkit, I can get the path to my attachment, such as /services/data/v21.0/sobjects/Attachments/someID/ and I make a URL as such:

 

https://cs3.salesforce.com/services/data/v21.0/sobjects/Contact/#id -H "Authorization: OAuth myToken"

 

I am getting an error message of [{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

 

Any suggestions? How should I go about entering the URL above (or any alternative URL that would work similarly) so that Salesforce acknowledges that I have already logged in once before?

 



dkadordkador

The only way you can pass a session ID is through the "Authorization" header of the HTTP request.  Your URL is correct to retrieve a particular Contact record (if it weren't you would get a 404).  You just need to make sure you're sending a valid session ID in the header.  Are you sure you're using the oauth "Access Token" as your session ID?  Do not use the "Authorization Code" for that.

konigswaggerkonigswagger

Reading the documentation on access tokens more thoroughly and it turns out, "OAuth access token cannot be used for access to the Force.com Web UI" (http://wiki.developerforce.com/index.php/Digging_Deeper_into_OAuth_2.0_on_Force.com). Thanks. Going to try a different route.

SuperfellSuperfell

Correct, but the REST api is not the Web UI, you can use an oauth access token to access the REST API.