2

I am trying to call a chatter API with in salesforce and i am getting the below error message. Error Message:

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

Code:

HttpRequest req = new HttpRequest();
req.setHeader('Content-type', 'application/json');
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
req.setEndpoint('https://xxxxxxx.my.salesforce.com/services/data/v36.0/chatter/feeds/record/005a0000009pkIg/feed-elements');
req.setMethod('GET');
Http http = new Http();
HTTPResponse res= http.send(req);
String response=res.getBody();
system.debug(response);
ParseChatter pschatter=(ParseChatter)JSON.deserialize(response,ParseChatter.class);
0

try this req.setHeader('Authorization', 'Bearer '+UserInfo.getSessionId());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.