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

http errors in callout
Hi developers,
I am getting 302, 401 & 404 status code errors from authentication to google api. what i am missing please help me
public class GoogleCalendar
{
public void detail()
{
Http h = new Http();
HttpRequest req = new HttpRequest();
final string username = 'sreenath.sfdc@gmail.com';
final string password = 'Password';
//final string apikey='AIzaSyDaQK60dlM-7icVukY0sbaOHae9eLn3dKk';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'BASIC ' +EncodingUtil.base64Encode(headerValue);
// auth url is https://www.googleapis.com/auth/calendar
req.setHeader('Authorization',authorizationHeader);
req.setHeader('Connection','keep-alive');
req.setHeader('Host','googleapis.com');
req.setHeader('Content-Type', 'application/Json');
req.setMethod('GET');
req.setbody('https://www.googleapis.com/auth/calendar?key=AIzaSyDaQK60dlM-7icVukY0sbaOHae9eLn3dKk');
//req.setbody(apikey);
req.setEndpoint('https://www.googleapis.com/calendar/v3/calendars/calendarId');
//req.setEndpoint('https://www.googleapis.com/calendar/v3/calendars/sreenath.sfdc@gmail.com/events/tea%20time?pp=1&key=AIzaSyDaQK60dlM-7icVukY0sbaOHae9eLn3dKk');
HttpResponse res = h.send(req);
system.debug('********'+res.getbody());
}
}
please find my log for issues, help me out
302 Moved
Hi Sreenath,
Check the url, It seems that the url that you are using is incorrect or changed.
Adi.
Hi adi,
You are correct but i am using the URL's which are providing in google api's. If you know this url's please post here.
Thanks
sreenath
I also got Status=Found, StatusCode=302.
In the API Access of Google apis, I cannot see any API request.
I guess the problem is how to login by http request.
I search the document of new version V3, but cannot find any example of how to login
google calendar with username/password/api key by Http request.
Anyone can help with this?
I am getting the same problem with another site..
Any pointers ??