When testing the Google Calendar API V3 by submitting a batch request from localhost, I am encountering the error message ""from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.". It's strange because a few months ago, I was able to successfully test batch submissions without any issues.
Below is the batch request being sent to the Google API via an Ajax POST:
function batch(data,calendarId){
var boundary = 'xxxxxxxx';
var batchRequest = '';
var payload = data.filter(function(curr,i,arr){
batchRequest = batchRequest +
"--"+boundary +
'\r\nContent-Type:application/http'+
'\r\nContent-ID:'+i+'\r\n\r\nPOST https://www.googleapis.com/calendar/v3/calendars/'+calendarId+'/events'+
'\r\nContent-Type: application/json' +
'\r\n\r\n' + JSON.stringify(curr) + "\r\n";
});
payload = batchRequest +'\r\n'+'--'+boundary+'--';
return payload;
}
Any thoughts or suggestions would be greatly appreciated.
Thank you, Ravi
Has anyone else tried sending batch requests to Google Calendar API 3 from localhost before? I'm looking for a solution to test batch requests from localhost to Google calendar API 3.