About Graph API permissions and settings

mahtycloud 1 Reputation point
2021-08-17T02:36:10.917+00:00

I want to register schedule-event by Graph API from
Graph Explorer as an administrator.

What I did was, I logged in to Graph Explorer as an administrator and Entered the following query.

[POST]
https://graph.microsoft.com/v1.0/users/{target user's id}/calendar/events

And in the request body, I described the following json format contents.

{
"subject": "Create by GraphAPI",
"body": {
"contentType": "HTML",
"content": "Does mid month work for you?"
},
"start": {
"dateTime": "2021-08-16T12:00:00",
"timeZone": "Tokyo Standard Time"
},
"end": {
"dateTime": "2021-08-16T14:00:00",
"timeZone": "Tokyo Standard Time"
},
"location": {
"displayName": "Headquarters meeting room"
}
}

After executing the above, the response preview returned json with the following content.

"code": "ErrorAccessDenied",
"message": "Access is denied. Check credentials and try again."

Regarding the access permission, the following have been granted.

Calendars.Read
Calendars.Read.Shared
Calendars.ReadWrite
Calendars.ReadWrite.Shared

Please tell me about the cause of the error and any other necessary settings.

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sheena-MSFT 1,736 Reputation points
    2021-12-22T14:18:12.687+00:00

    Hi @mahtycloud ,

    For creating events in a user calendar by using delegated permission in Graph Explorer, the targeted user must share their calendar explicitly with "delegate only" or "can edit" permission.

    To share the calendar you can follow the below steps in outlook:

    In calendar Home page click on settings and select view all outlook settings

    159669-ss2.png

    From settings select calendar ->Shared calendars ->select a calendar
    159670-ss3.png

    Choose the user you want to share the calendar and add the permission "can edit" or "delegate"

    159689-ss4.png

    To create event for the targeted user you can use calendars.ReadWrite.Shared permission

    POST https://graph.microsoft.com/v1.0/users/{userid}/calendar/events  
    

    Example:

    159705-ss5.png

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.