+ Start a Discussion
ashish raiashish rai 

How to make httprequest with access token with example

Hi all,

      Please any one send me the exact code for httprequest with accesstoken to retrive one org date from anothe org. I am sing this but geting respone as  Bad_OAuth_Token. So tell me what i am doing wrong in below code:

 

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);