0
votes

I'm creating a Microsoft graph webhook so an Azure Function triggers when a new email arrives to my Inbox.

My setup is:

  • dotnet Azure Function with an MSGraph "Outlook message webhook creator"

Outlook messagewebhook creator

  • A MultiTenant Microsoft App so my Azure Active Directory can ask for permissions Mail.Read

The problem is: after accepting the requested permissions, Graph returns "Invalid request" Subscription validation request failed. Must respond with 200 OK to this request.

I also tried to create the subscription manually via the Microsoft Graph Explorer but the error is consistent Error Graph Explorer

1
I too have a similar issue. my notification url is azure function and I don't receive the validationToken in azure function to validate. - Kannan Karmegam

1 Answers

0
votes

According to the error, the notificationUrl in your request body is invalid.

The subscription notification endpoint (specified in the notificationUrl property) must be capable of responding to a validation request as described in Set up notifications for changes in user data. If validation fails, the request to create the subscription returns a 400 Bad Request error.

POST https://graph.microsoft.com/v1.0/subscriptions
Content-type: application/json

{
   "changeType": "created,updated",
   "notificationUrl": "https://webhook.azurewebsites.net/api/send/myNotifyClient",
   "resource": "me/mailFolders('Inbox')/messages",
   "expirationDateTime":"2016-11-20T18:23:45.9356913Z",
   "clientState": "secretClientValue"
}

See reference - Notification endpoint validation.