Reputation: 429
Using a daemon/service application with the Outlook Calendar REST API, I want to be able to make a user attend an existing event created by another user. The attending user is not invited to it beforehand. In other words, I want to program both inviting a user to a event and the user accepting it, in one step.
As I read the API documentation, the only way I can do this is to:
1) Get the attendees array for the event
GET https://outlook.office.com/api/users/{eventauthor_mail}/events/{event_id}
The attendees will be an array:
"Attendees": [
{
"EmailAddress": {
"Address": "janets@a830edad9050849NDA1.onmicrosoft.com",
"Name": "Janet Schorr"
},
"Status": {
"Response": "None",
"Time": "0001-01-01T00:00:00Z"
},
"Type": "Required"
},
...
],
2) Extend the Attendees array
Now I need to extend the attendees array, something like this in PHP:
array_push($attendees, array(
"EmailAddress" => array(
"Address" => $newAttendeeMail,
"Name" => $newAttendeeName
),
"Status" => array(
"Response" => $newAttendeeStatus,
"Time" => $newAttendeeTime
),
"Type" => $newAttendeeType
));
3) Update the event
Send an application/json
request including the extended attendees array in the body:
PATCH https://outlook.office.com/api/{version}/users/{eventauthor_mail}/events/{event_id}
Is there a way I can do this better? I find it a bit cumbersome that I have to download the whole attendees list, add a new attendee to it and then upload the whole (extended) list back. This does not seem like best practice to me...
Thank you in advance for the advice!
Upvotes: 0
Views: 636
Reputation: 3302
You need to call Update Event and add the new attendee to the attendees' list. Once you add this attendees, the object will be updated with the added attendee.
Update Event Url: https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#EventResource
In the body of the request, update the attendees list since it is a writable prperty: https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#EventResource
Upvotes: 0