Home > Blockchain >  Graph API Call Issues - POST Event
Graph API Call Issues - POST Event

Time:04-22

I'm running into issues when trying to create an event in a specific user calendar.

This call works fine: POST enter image description here

Error:

enter image description here

Can someone please assist if I'm missing something?

CodePudding user response:

Please note when you use /me, it means you are calling the ms graph api with a delegate api permission which is authentiated by entering user name/password, you can only do operations on your own account with this kind of authentication. While you want to do operations for other users like /users/user_id/xxx, you required the application api permission. That's why enter image description here

using Azure.Identity;
using Microsoft.Graph;
public async Task<string> testAsync() {
    var scopes = new[] { "https://graph.microsoft.com/.default" };
    var tenantId = "tenant_name.onmicrosoft.com";
    var clientId = "azure_ad_clientid";
    var clientSecret = "client_secret";
    var clientSecretCredential = new ClientSecretCredential(
        tenantId, clientId, clientSecret);
    var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
    var a = await graphClient.Users["user_id"].Request().GetAsync();
    return a.DisplayName;
}
  • Related