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

HTTP Callout from Salesforce
Hi there,
I have been trying to get response from Google Analytics API. I have the access token. Can you please suggest the correct syntax of embedding the token in GET Response
Thanks in advance
I have been trying to get response from Google Analytics API. I have the access token. Can you please suggest the correct syntax of embedding the token in GET Response
Thanks in advance
You can refer the below code to embed the token in your GET call.
Http h = new Http();
HttpRequest req = new HttpRequest();
string endPointValue = 'https://www.googleapis.com/calendar/v3/calendars/primary/events'; // Your End Point URL
req.setEndpoint(endPointValue);
req.setHeader('Authorization', 'Bearer ' + ACCESS_TOKEN);
req.setMethod('GET');
req.setTimeout(10000);
HttpResponse res = h.send(req);
Regards,
Grazitti Team
I have tried this but I am getting Status Code as 403 (Forbidden). Also my endPoint URL has parameters associated to it
Thanks and Regards
You can aapend the parameters in the setBody() as follows:
HttpRequest req = new HttpRequest();
string bodyRequest = '';
bodyRequest = 'param1=' + paramVal;
bodyRequest += '¶m2 =' + paramVal2;
req.setBody(bodyRequest);
and it seems you have to add "https://www.googleapis.com" in your remote site settings of salesforce org to fix the Status code 403 .
Hope it helps you.
Regards,
Grazitti Team
I am still getting System.HttpResponse[Status=Not Found, StatusCode=404]. Remote Site settings for URL is active.
Thanks ans Regards
This might be due to some problem in your access token that you are using to fetch the data (access token might be expired).
Thanks!