0

I am trying to develop an app similar to what was asked in this question

I have configured the app in the Azure Portal with the proper permissions and followed the guide here.

The application appears to be getting the proper token from AD using the scope https://graph.microsoft.com/.default

After the call is made, it responds with a "Method Not Found" error.

Code: UnknownError
Message: Method not allowed
Inner error:
    AdditionalData:
    date: 2020-10-11T21:36:03
    request-id: ...
    client-request-id: ...
ClientRequestId: ...

The request-id, client-request-id, and ClientRequestId all have the same value.

Is there a way to troubleshoot why this error occurs with the Ids returned? Is there something I am missing in my configuration?

The purpose of this app is to self-register volunteers for a Give Camp we are holding and will use Microsoft Teams as the collaboration tool. If there is a better way to do this, I am open to suggestions.

The code can be found here https://github.com/swogc/GiveCamp-Teams

Permissions granted for app: Permissions granted for app

Mike Therien
  • 928
  • 3
  • 10
  • 25
  • Make sure in your app registration, you've configured the API permissions and clicked the button to grant admin consent. – Jason P Oct 11 '20 at 23:12
  • Could you share your HTTP request url? Creating invitation needs to use **POST**. And permissions can also need to grant admin consent as Jason said. – unknown Oct 12 '20 at 01:17
  • @PamelaPeng - This is using the Microsoft Graph library, so I would assume it was doing a post. [Ref Line](https://github.com/swogc/GiveCamp-Teams/blob/3629f8f5363c7227485e0b874d3bc2fbd32ec734/SWOGCInvite/Services/InvitationService.cs#L47) – Mike Therien Oct 12 '20 at 12:31
  • @JasonP I believe I have the correct permissions configured. I updated the post with a screenshot of the permissions – Mike Therien Oct 12 '20 at 12:35

1 Answers1

0

It seems both permissions and post are all right. If the application is authorized without user, you could refer to here and use Client credentials provider to call the MS graph API.

string[] scopes = { "https://graph.microsoft.com/.default" };

IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                            .Create(clientId)
                            .WithTenantId(tenantID)
                            .WithClientSecret(clientSecret)
                            .Build();

ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication, scopes);

GraphServiceClient graphClient = new GraphServiceClient(authProvider);

var invitation = new Invitation
{
    InvitedUserEmailAddress = "pamela@xxx",
    InviteRedirectUrl = "https://southwestohiogivecamp.org",
    
};

await graphClient.Invitations.Request().AddAsync(invitation);
unknown
  • 6,778
  • 1
  • 5
  • 14