fix: Outlook update/delete fallback to non-calendar-scoped endpoint

When the calendar-scoped Graph API endpoint returns 404 for series
master or instance IDs, fall back to /me/events/{id} which handles
these cases. Fixes ErrorItemNotFound on delete/update of recurring
Outlook events.

v1.63.5

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mARTin 2026-03-24 10:51:03 +01:00
parent c718aa584a
commit 18c2fc1a92
2 changed files with 58 additions and 37 deletions

View File

@ -1,6 +1,6 @@
{
"name": "my-weekly-todo-list",
"version": "1.63.4",
"version": "1.63.5",
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
"main": "index.js",
"scripts": {

View File

@ -341,13 +341,7 @@ export const updateEvent = async (
eventId: string,
event: any
) => {
const response = await fetch(`${GRAPH_ENDPOINT}/me/calendars/${encodeURIComponent(calendarId)}/events/${encodeURIComponent(eventId)}`, {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
const body = JSON.stringify({
subject: event.summary,
body: {
contentType: 'HTML',
@ -376,9 +370,25 @@ export const updateEvent = async (
type: 'required',
})),
} : {}),
})
});
const patchHeaders = {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
};
// Try calendar-scoped endpoint first
let response = await fetch(`${GRAPH_ENDPOINT}/me/calendars/${encodeURIComponent(calendarId)}/events/${encodeURIComponent(eventId)}`, {
method: 'PATCH', headers: patchHeaders, body
});
if (!response.ok && response.status === 404) {
// Fallback: try non-calendar-scoped endpoint
response = await fetch(`${GRAPH_ENDPOINT}/me/events/${encodeURIComponent(eventId)}`, {
method: 'PATCH', headers: patchHeaders, body
});
}
if (!response.ok) {
const err = await response.text();
throw new Error(`Failed to update Outlook event: ${err}`);
@ -404,13 +414,24 @@ export const deleteEvent = async (
calendarId: string,
eventId: string
) => {
const response = await fetch(`${GRAPH_ENDPOINT}/me/calendars/${encodeURIComponent(calendarId)}/events/${encodeURIComponent(eventId)}`, {
// Try calendar-scoped endpoint first
let response = await fetch(`${GRAPH_ENDPOINT}/me/calendars/${encodeURIComponent(calendarId)}/events/${encodeURIComponent(eventId)}`, {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
if (!response.ok && response.status === 404) {
// Fallback: try non-calendar-scoped endpoint (works better for series master IDs)
response = await fetch(`${GRAPH_ENDPOINT}/me/events/${encodeURIComponent(eventId)}`, {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
}
if (!response.ok) {
const err = await response.text();
throw new Error(`Failed to delete Outlook event: ${err}`);