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
CloudHuggerCloudHugger 

error:[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

Hi All,

 

I am attempting to use the REST API and its proving a real struggle at this last step - any help most appreciated!

 

Am trying to use the username-password flow to get oauth session token and uri.

I pass in the various parameters and am successfully returned a session token and uri. All good.

I get a session token and uri, so then try to do a describe, via a HTTP GET using uri + '/services/data/v20.0/sobjects/Account/describe' 

I have locked session to IP

 

All I get is error:[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

 

Any suggestions....?

 

Best Answer chosen by Admin (Salesforce Developers) 
CloudHuggerCloudHugger

LoL - Simon - in assisting as you have, you inadvertedly got me to a working REST transaction to salesforce...

 

I'd been using xhr.setRequestHeader('Authorization','OAuth: '+sessiontoken); [Appcelerator Titanium] and after weeks of trying the colon in request header was the culprit.  DOH!

 

Thanks for your speedy support - we got there!

 

Cheers,

Carl

 

All Answers

SuperfellSuperfell

Sounds like you're not adding the Authorization: OAuth {someAccessToken} http header to your request.

CloudHuggerCloudHugger

Thanks Simon for quick feedback.

 

Unfortunately I am putting token in header of request prior to sending.  Given I am receiving the token back in JSON format, and parsing out the token should I be decoding it, or processing it some other way prior to trying to use it?

 

Any thoughts most appreciated!

 

 

SuperfellSuperfell

Can you show exacly how you have the header, the OAuth part of the header value is case sensitive.

CloudHuggerCloudHugger

LoL - Simon - in assisting as you have, you inadvertedly got me to a working REST transaction to salesforce...

 

I'd been using xhr.setRequestHeader('Authorization','OAuth: '+sessiontoken); [Appcelerator Titanium] and after weeks of trying the colon in request header was the culprit.  DOH!

 

Thanks for your speedy support - we got there!

 

Cheers,

Carl

 

This was selected as the best answer