Basically I have this piece of code written in my chrome extension...
await fetch(
"https://www.googleapis.com/calendar/v3/calendars/primary/events?sendUpdates=all&sendNotifications=true&alt=json&key=<API_KEY>",
{
method: "POST",
headers: {
Authorization: "Bearer " + token.token, // Token is proper... verified
Accept: "application/json",
},
body: JSON.stringify({
end: {
dateTime: "03-02-2022" + "T23:59:00.000+05:30",
},
start: {
dateTime: "03-02-2022" + "T23:00:00.000+05:30",
},
eventType: "default",
description: "event",
summary: "Digital Assignment",
}),
}
)
.then(async (res) => {
return res.json();
})
.then((data) => {
resolve();
console.log(data);
})
This used to work before... but for some reason now it doesn't work... The API hits with error
{"error": {"code":400,"errors":[{"domain":"global","message":"Bad Request","reason":"badRequest"}],"message":"Bad Request"}}
I even tried on Google's API explorer... It also gives same error... Are there new updates to API... I read documentation but I'm not able to figure it out...
For more details, you can check this repo where I'm using calendar API... https://github.com/sudonims/vtop-da-deadline/blob/master/background.js#L60