Calling API to create an event, What am I doing wrong?

Saúl Alvarado 1 Reputation point
2021-08-23T16:48:01.707+00:00

Hello there

I've been trying to call Microsoft Graph API for creating events, however I've not been able to do it.
Context: I have a Web MVC application (C#) already in production, with the "common" authentication method, reading a database of users. Recently the customer asked me the possibility to create Microsoft Teams Meetings from the application and also those created meetings have to be scheduled in the Microsoft Teams Calendar with the "Join" button to enter the meeting.

I already configured the API permissions, client secret and used the other properties like tenant, user id, etc from the Azure Portal, I'm sharing screenshots of my code and configuration. I'm doing the "Get access on behalf of a user" process.

API Permissions:

125570-permissions.png

Taking the example of the authorize endpoint from the docs, of course I'm replacing the values with my own info

https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
client_id=11111111-1111-1111-1111-111111111111
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
&response_mode=query
&scope=offline_access%20user.read%20mail.read
&state=12345

Here is my code to Receive the code once the user authorizes the permissions, I'm just storing the value in a static class for testing

125559-receivecode.png

Once I got the Auth code, I'm using it to create the event with the generated token, also I already verified that the token contains the permissions given in the Azure Portal.

This is the input for the /events endpoint, is too long that's why I'm taking a different screenshot

125722-json.png

This is the complete method, for the json value, please see the json above this screenshot. I also tried with the "me" url but it does not work either.

125704-method.png

I'm able to the get the token, but when trying to create the event returns the next response.

125717-message.png

Am I missing something? Maybe the wrong endpoint?
Please, help.
Thanks in advance.

Microsoft Teams Development
Microsoft Security Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. Sayali-MSFT 3,991 Reputation points Microsoft External Staff Moderator
    2023-07-28T10:16:52.3833333+00:00
    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.