setting event organizer with Outlook Calendar REST

2019-06-04 20:55发布

I am using the Outlook REST API for creating events and sending its invitations, based on this documentation

I authenticate the logged in user, and send its Bearer token through the Authorization header of the request, and the json-formatted event on its content.

If I set the "Organizer" to another user rather than the authenticated one, as well as the "IsOrganizer" property to "false", it gets totally ignored and sets the current logged in user as the organizer.

Any clues of what could be happening? Is there another way of doing this?

Thank you!

2条回答
你好瞎i
2楼-- · 2019-06-04 21:25

I'm posting this in case someone else finds and needs an answer for this scenario...

You (Account A) can create a calendar event as someone else (Account B) through Office365 REST APIs as long as the account has permission to send as the other user account.

Here are the steps:

1) Call the Office365 REST API as follows,where {{{user2email}}} is the user you want the event to be created as (Account B's email address): https://outlook.office365.com/api/v1.0/users/{{{user2email}}}/calendar

This should return Account B's user's calendar ID.

2) Pass in your JSON - the following is an example of what I used during unit testing:

{
      "Subject": "Test - Created using Office365 Calendar REST API should be from Technology Notice",
      "IsOrganizer": "False",
      "Body": {
        "ContentType": "HTML",
        "Content": "This is where body copy goes HTML supported"
      },
      "Start": "2015-12-11T19:00:00Z",
      "End": "2015-12-11T20:00:00Z",
      "Attendees": [
        {
          "EmailAddress": {
            "Address": "attendee1@yourcompany.com",
            "Name": "Attendee One"
          },
          "Type": "Required"
        }
      ],
      "Organizer": {
        "EmailAddress": {
          "Address": "tnotice@yourcompany.com",
          "Name": "Technology Notice"
        }
      }
    }

'Technology Notice' will be who the calendar invite is from.

3) Use the ID from step 2 in your POST request, for example: https://outlook.office365.com/api/v1.0/users/{{{user2email}}}/calendars/{{{ID}}}/events

Note: Make sure you're sending the POST request as the authenticated user account (Account A) who's account the mailbox/calendar it actually belongs to.

If everything is right you should be able to send a calendar invite and have it show up as originating from Account B instead of Account A.

Hope this helps someone out.

查看更多
别忘想泡老子
3楼-- · 2019-06-04 21:27

This is the correct behavior. You cannot create an event on User A's calendar but set the organizer to User B.

查看更多
登录 后发表回答