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

How to make http request with access token
Hi all,
can any one help we the exact httpreqest with access token . I am using this but getiing a response "Bad_OAuth_Token" which comes when you are passing the wrong token.
httprequest hreq=new httprequest();
hreq.Setendpoint('https://login.salesforce.com/id/00D90000000aSjoEAE/00590000000eb7cAAA');
hreq.setmethod('POST');
hreq.setHeader('Authorization: ','OAuth 00D90000000aSjo!AQgAQNfbCS3aunHX37ko2VhwXzk4holpYFrU9juuCIMdanXC54DAjI916nYNvzZHjOV2vRubCiT1XZGeongMBAVxtdMfpLlN');
hreq.setHeader('Host','https://ap1.salesforce.com');
http htp=new http();
httpResponse res=htp.send(hreq);system.debug('%%%%%%%%%%%%%' +res);
System.debug('@@@@@@@@' +res.getBody());
Can any one help me on this???????????????
Take the colon out of the Authoriztion string in your call to setHeader.
There's also no need to set the Host header, that'll be done for you.
And i beleive the Id endpoint is expecting a GET request, not a POST.
Hi Simon,
Can you post the exact httprequest having access token. Please go through the below that what i am doing wrong in that
because i am geting the same response that is Bad_OAuth_Token. When i remove the set host header the response i am geting is null. Please help me on that:
httprequest hreq=new httprequest();
hreq.Setendpoint('https://login.salesforce.com/id/00D90000000aSjoEAE/00590000000eb7cAAA');
hreq.setmethod('GET');
hreq.setHeader('Authorization',':OAuth 00D90000000aSjo!AQgAQIRuHIv1pXGwo306PxvZCcgeDp_S__T1jWwarX9KNUzCQO74prs0xPfoE49S7GGHWUkubZlA.q_6N34TPj9036UaPNPt');
//hreq.setHeader('Host','https://ap1.salesforce.com');
http htp=new http();
httpResponse res=htp.send(hreq);
system.debug('%%%%%%%%%%%%%' +res);
System.debug('@@@@@@@@' +res.getBody());