iosobjective-crestoffice365

Responding to an Office 365 event invite via REST


I'm currently working on adding functionality to allow a user to respond to an Office 365 event invitation (accept/maybe/decline) via their REST API. I'm not entirely sure how developers are supposed to utilize this functionality via the API, however.

Google, for example, has a attendeesOmitted flag that you can set to true, then pass in the updated invitees on their normal event update endpoint.

I don't see any of this functionality on Office 365's API, though. I have tried the following code to update invitations, but it has no effect on the status of the user (though it does return a 200 success message):

NSMutableDictionary *params = [ActivityCommon parametersFromEvent:event type:service dateOnly:TRUE]; //Don't need all params
[params setObject:@[@{@"EmailAddress": @{@"Name": invitee[@"Name"],
                                         @"Address": invitee[@"Email"]},
                      @"Status": @{@"Response": @"Accepted"},
                      @"Type": @"Required"}] forKey:@"Attendees"];

[networkMgr PATCH:[NSString stringWithFormat:@"events/%@", identifier] parameters:params success:nil failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    
    NSLog(@"%@", operation.responseObject);
}];

Has anyone had any experience with this? Any insights would be much appreciated!


Solution

  • The meeting invitation will show up as a Message in the user's inbox. You would use the Mail API to access this. For the most part it looks like a normal email, but it has a few extra properties.

      "MeetingMessageType": "MeetingRequest",
      "Event@odata.navigationLink": "https://outlook.office365.com/api/v1.0/Users('user@domain.com')/Events('AAMkADRm...')"
    

    By using the value of the Event@odata.navigationLink property, you can access the corresponding Event on the user's calendar using the Calendar API.

    On the Event, you can use the Accept, Decline, or TentativelyAccept actions. (See https://outlook.office365.com/api/v1.0/$metadata for the full declaration).

    So for example, if you want to accept the meeting invite, you would do something like:

    POST /Me/Events('AAMkADRm...')/Accept
    
    {
      "Comment": "I will be there!",
      "SendResponse": true
    }
    

    The organizer gets the acceptance message with the text "I will be there!".