In the Microsoft graph API - notificationUrl return 406 error

Suhel Inamdar 6 Reputation points
2022-07-21T11:24:44.157+00:00

I am using Microsoft Graph API(beta version), in that I wrote a webhook to create a subscription.
Endpoint:- https://graph.microsoft.com/beta/subscriptions
Request Body(Payload):- {
"changeType": "created",
"notificationUrl": "....webhook/you_have_microsoft_mail",
"resource": "me/messages",
"expirationDateTime":"2022-07-23T07:00:57.069804+00:00",
"clientState": "subscription-identifier"
}

So, it gives me error as a 400 Bad request with error message:- "Subscription validation request failed. Notification endpoint must respond with 200 OK to validation request."

I investigated issue further and I got the issue with NotificationUrl, it always return an error 406 not acceptable

But I tried same NotificationUrl with same token on the Postman, it works fine but with webhook it return 406 error

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,001 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 6,056 Reputation points
    2022-08-02T14:46:36.117+00:00

    Hi @Suhel Inamdar

    According to this documentation, error code 406 signifies "This service doesn’t support the format requested in the Accept header."
    The "Accept" header field can be used by user agents to specify response media types that are acceptable.
    Please ensure that you are using right content-type.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote. If you have further questions about this answer, please click "Comment".


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.