问题
The add attachment endpoint seems buggy. Files attached to a calendar event are not visible to the calendar recipients. The attachments are visible to the event creator. My code had been working for months until recently, which leads me to believe this is a regression.
Steps to reproduce
- There must be two users - the creator and the recipient.
- Create an event via
https://graph.microsoft.com/v1.0/me/calendars/{calendarId}/events
- Attach a file to the event via
https://graph.microsoft.com/v1.0/me/calendars/{calendarId}/events/{eventId}/attachments
- Go to the Office 365 web UI as the creator. The event looks good and includes the attachment.
- Query the Microsoft graph API as the creator. The event looks good.
hasAttachments
istrue
and listing the attachments via the API works as expected. - Go to the Office 365 web UI as the recipient. The event is missing the attachment (everything else about the event is accurate).
- Query the Microsoft graph API as the recipient.
hasAttachments
isfalse
and you can not list the attachments with the graph API. To get the recipient's event ID, I queried the/calendarView
endpoint. It returns a different event id than the event in step 4, but the rest of the object matches (iCalUId, subject, start/end times, etc)...with the exception ofhasAttachments
.
Fixes attempted
I tried creating the event and attaching the file via the /users/{userId}
endpoints instead of the /me
endpoints with the same results.
I also tried the add attachment beta endpoint but received the following error:
{
"error": {
"code": "NavigationNotSupported",
"message": "Recursive navigation is not allowed after property 'Events' according to the entity schema.",
"innerError": {
"request-id": “{uuid}”,
"date": "2018-06-06T06:28:47"
}
}
}
回答1:
Marc's workaround fixes the issue - add the attendees after the attachments. A working flow looks like:
- Create an event (excluding attendees) via POST to
https://graph.microsoft.com/v1.0/me/calendars/{calendarId}/events
. - Attach a file to the event via POST to
https://graph.microsoft.com/v1.0/me/calendars/{calendarId}/events/{eventId}/attachments
- Update the event from step 1 with the attendees via PATCH to
https://graph.microsoft.com/v1.0/me/calendars/{calendarId}/events/{eventId}
A few extra requests, but it gets the job done.
来源:https://stackoverflow.com/questions/50714919/office365-rest-api-calendar-event-attachments-not-visible-for-recipients