I am trying a create an google calendar event using API...But i am getting error while trying to create event..I am getting access token succesfully but not able to create calendar events...
Please help i am trying to sort out this from the last 2 days...I think this is some perrmision issue...I am using below scope.
any help will be highly appreciated.
String scope='https://www.googleapis.com/auth/calendar';
Http h = new Http();
string calendarId='a@b.com';
string url='https://www.googleapis.com/calendar/v3/calendars/'+calendarId+'/events';
string body='{"end":{"date": "2013-06-21"},"start":{"date": "2013-06-20"}}';
HttpRequest req=new HttpRequest();
System.debug('-----accesstokenvvvvvvvv---'+accesstoken);
req.setHeader('Authorization','Bearer '+accesstoken);
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(url);
req.setBody(body);
System.debug('-----body---'+body);
req.setMethod('POST');
HttpResponse res;
res = h.send(req);
string data=res.getBody();
System.debug('--------data----'+data);
I am getting error response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}