javascript - gapi.client.load() results 404 Error for google calendar v3 -
code -
var request = gapi.client.calendar.events.insert({ 'calendarid': 'primary', 'resource': event }); request.execute(function(event) { console.log('event created: ' + event.htmllink); });
and gives url follow
i couldn't find reason. problem in api key or else?
oops! sorry have found solution of problem. event object sending calendar wrong. working fine.it silly mistake of mine.this total code , working fine me.......
var client_id = 'myclientid'; var scopes = ["https://www.googleapis.com/auth/calendar"]; var evntjsn = ''; function addeventingoogle(eventlist){ evntjsn = eventlist; var apikey = 'myapikey'; gapi.client.setapikey(apikey); gapi.auth.authorize( { 'client_id': client_id, 'scope': scopes.join(' '), 'immediate': true }, handleauthresult); } /** * handle response authorization server. * * @param {object} authresult authorization result. */ function handleauthresult(authresult){ if (authresult && !authresult.error) { loadcalendarapi(); } else { handleauthclick(event); } } /** * initiate auth flow in response user clicking authorize button. * * @param {event} event button click event. */ function handleauthclick(event) { gapi.auth.authorize( { client_id: client_id, scope: scopes, immediate: false }, handleauthresult); return false; } function loadcalendarapi() { gapi.client.load('calendar', 'v3', addeventtogglcalendar); } function addeventtogglcalendar(){ var event = evntjsn; var request = gapi.client.calendar.events.insert({ 'calendarid': 'primary', 'resource': event }); request.execute(function(event) { console.log(event); }); }
Comments
Post a Comment