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:
parent
c718aa584a
commit
18c2fc1a92
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "my-weekly-todo-list",
|
"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",
|
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -341,13 +341,7 @@ export const updateEvent = async (
|
|||||||
eventId: string,
|
eventId: string,
|
||||||
event: any
|
event: any
|
||||||
) => {
|
) => {
|
||||||
const response = await fetch(`${GRAPH_ENDPOINT}/me/calendars/${encodeURIComponent(calendarId)}/events/${encodeURIComponent(eventId)}`, {
|
const body = JSON.stringify({
|
||||||
method: 'PATCH',
|
|
||||||
headers: {
|
|
||||||
'Authorization': `Bearer ${accessToken}`,
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
subject: event.summary,
|
subject: event.summary,
|
||||||
body: {
|
body: {
|
||||||
contentType: 'HTML',
|
contentType: 'HTML',
|
||||||
@ -376,9 +370,25 @@ export const updateEvent = async (
|
|||||||
type: 'required',
|
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) {
|
if (!response.ok) {
|
||||||
const err = await response.text();
|
const err = await response.text();
|
||||||
throw new Error(`Failed to update Outlook event: ${err}`);
|
throw new Error(`Failed to update Outlook event: ${err}`);
|
||||||
@ -404,13 +414,24 @@ export const deleteEvent = async (
|
|||||||
calendarId: string,
|
calendarId: string,
|
||||||
eventId: 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',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${accessToken}`
|
'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) {
|
if (!response.ok) {
|
||||||
const err = await response.text();
|
const err = await response.text();
|
||||||
throw new Error(`Failed to delete Outlook event: ${err}`);
|
throw new Error(`Failed to delete Outlook event: ${err}`);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user