How to send meeting request wirh different sender Microsoft graph API

Mishra, Dolly 41 Reputation points
2020-07-22T05:42:38.397+00:00

My requirement me that I am getting sender infor, attendees info and I need to send meeting request
I am using Microsoft graph Create event method, I could see that in request JSON "attendees" are there
but how to use "organizer".

Currently when I call this API, it sends meeting request from my emailid and not the sender emailid which I have got.


organizer i am giving, but its always sending frm my ID. and not the one mentioned below


{
"subject":"Let's go for lunch",
"body":{
"contentType":"HTML",
"content":"Does late morning work for you?"
},
"start":{
"dateTime":"2020-08-15T12:00:00",
"timeZone":"Pacific Standard Time"
},
"end":{
"dateTime":"2020-08-15T14:00:00",
"timeZone":"Pacific Standard Time"
},
"location":{
"displayName":"Harry's Bar"
},
"organizer":{
"emailAddress":{
"name":"Raja Booth",
"address":"---------"
}
},
"attendees":[
{
"emailAddress":{
"address":"------------",
"name":"kanchan"
},
"type":"required"
}
]
}

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,645 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,559 questions
0 comments No comments
{count} votes

Accepted answer
  1. soumi-MSFT 11,716 Reputation points Microsoft Employee
    2020-07-24T07:59:09.92+00:00

    @MishraDolly-9847, Thank you for sharing the details. Lets understand the auth process a bit that would be used in this case. To call the AAD protected APIs like Microsoft Graph API, you would need an access token issued by AAD for Graph API to consume before you can use the API to fetch the required information or perform a specific task. To get the access-token from AAD, you can flow either of the two ways:

    Authorization-Code Grant Flow: This flow is usually used to get a user signed in using a browser and after successful authentication, AAD would issue an access-token in user's context. This flow needs an Interactive Login process, i.e entering the username and password manually when prompted for by AAD.

    Client-Credential Flow: This flow is used, when an application would need to fetch an access-token from AAD. This flow issues an access-token in application's context after authenticating the application registered in AAD. This flow is a non-interactive flow but only works in case of applications.

    Now, for you can since you are using the /events graph API, you would need to use the Authorization-Code Grant flow to fetch a token from AAD, as this API would work only when the token issue to the user who just authenticated itself with AAD and provides the token that AAD issued to him/her.

    As per your query "but in the meeting, request sender will be a different person which I should be able to pass while calling API", you can do that by following the steps mentioned below:

    First of all the other person on whose behalf you would be sending the invite, he/she should get his calendar shared with you. You can check the following article to get the understanding on how to do that: https://www.microsoft.com/en-us/microsoft-365/blog/2013/09/04/configuring-delegate-access-in-outlook-web-app/

    Once the calendar is shared with you, now perform the steps to get an access-token from AAD on for yourself and then call the following Graph API: GET https://graph.microsoft.com/v1.0/me/calendars

    From the output of the previous Graph API call, you can fetch the calendar Id of the shared calendar and then next you can call the second graph api to send the invitation:

    POST https://graph.microsoft.com/v1.0/me/calendars/AAMkADRpAABf0JlzAAA=/events

    Prefer: outlook.timezone="Pacific Standard Time"
    
    Content-type: application/json
    
    "subject": "Christmas dinner",
    "body": {
        "contentType": "HTML",
        "content": "Happy holidays!"
    },
    "start": {
        "dateTime": "2019-12-25T18:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "end": {
        "dateTime": "2019-12-25T22:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "location":{
        "displayName":"Alex' home"
    },
    "attendees": [
    {
       "emailAddress": {
            "address":"meganb@contoso.onmicrosoft.com",
            "name": "Megan Bowen"
        },
        "type": "required"
    },
    {
        "emailAddress": {
            "address":"ChristieC@contoso.onmicrosoft.com",
            "name": "Christie Cline"
        },
        "type": "required"
    }
    ]
    }
    

    More details can be found here: https://learn.microsoft.com/en-us/graph/outlook-create-event-in-shared-delegated-calendar?tabs=http

    Once the invitation is sent, you would find the organizer as the other person, on whose behalf you have sent the email. In my case, I have used two users dummyuser1 and dummyuser2. Dummyuser1 has shared his calendar with dummyuser2 and then dummyuser2 uses the shared calendar to send the invite.

    13570-createeventapi.png

    Hope this helps.

    Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as Answer; if the above response helped in answering your query.


3 additional answers

Sort by: Most helpful
  1. soumi-MSFT 11,716 Reputation points Microsoft Employee
    2020-07-22T14:48:27.88+00:00

    @MishraDolly-9847, Thank you for reaching out. I tested this API and the way it works is, the sender and organizer would be the same person who is calling this API using the accessToken. In other words, the user who has requested for the token from AAD, that person's name would be in the sender's and organizer's place.

    13130-calenderinvite.png

    You can take a look at the API call and also the body for that API call in the screenshot below for reference:

    13308-createeventapi.png

    The body should looks something like:

     {
       "subject": "Let's go for lunch",
       "body": {
         "contentType": "HTML",
         "content": "Does next month work for you?"
       },
       "start": {
           "dateTime": "2019-03-10T12:00:00",
           "timeZone": "Pacific Standard Time"
       },
       "end": {
           "dateTime": "2019-03-10T14:00:00",
           "timeZone": "Pacific Standard Time"
       },
       "location":{
           "displayName":"Harry's Bar"
       },
       "attendees": [
         {
           "emailAddress": {
             "address":"adelev@contoso.onmicrosoft.com",
             "name": "Adele Vance"
           },
           "type": "required"
         }
       ],
       "isOnlineMeeting": true,
       "onlineMeetingProvider": "teamsForBusiness"
     }
    

    Hope this helps.

    Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as Answer; if the above response helped in answering your query.

    1 person found this answer helpful.

  2. Mishra, Dolly 41 Reputation points
    2020-07-23T10:16:23.563+00:00

    Thanks so much for the reply. However Regarding "API using the accessToken.
    In other words, the user who has requested for the token from AAD"

    Can you please let me know how to get this token? And How to pass this token when scheduling meeting request by calling Create Event API

    In my usecase, I am calling the API methods ( calendarid, user secret.. are mine)
    but in the meeting request sender will be different person which i should be able to pass while calling API

    0 comments No comments

  3. Mishra, Dolly 41 Reputation points
    2020-07-28T06:40:02.103+00:00

    Thanks so much for detailed explanation. REally helped.

    I posted one more question
    https://learn.microsoft.com/en-us/answers/questions/53401/microsoft-graph-api-provider-calendar-persmission.html

    Can you help please?