You need to sign in to do that
Don't have an account?
Trying to call chatter rest from a visual force page on the same org - HTTP response 302
Hi,
I am trying to call the chatter rest api from a visual force page from the same org. While my code works if I put it in the developer console - however , from the Visual force page I get the Http response 302 - not sure what is happening. Here is my apex code :
String salesforceHost = System.Url.getSalesforceBaseURL().toExternalForm();
String url = salesforceHost + '/services/data/v27.0/chatter/feeds/record/' + oTaskDetail.sato.Id + '/feed-items';
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint(url);
req.setHeader('Content-type', 'application/json');
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
String UserId = String.ValueOf(UserInfo.getuserId());
String ChatterPostText = CreateChatterPost();
req.setBody('{ "body" : { "messageSegments" : [ { "type": "mention", "id" : "' + UserId + '" }, { "type": "text", "text" : "' + ' ' + ChatterPostText + '" } ] } }');
Http http = new Http();
HTTPResponse res = http.send(req);
any help on this would be greatly appreciated. Thanks