Graph Subscription API Error ValidationError

Akbar Putra 20 Reputation points
2024-04-30T06:56:38.8166667+00:00

I'm trying to call post API to create a subscription with this body, but returned ValidationError without any description. Can someone help me?

User's image

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Sourabh Gupta 800 Reputation points Microsoft External Staff
    2024-05-04T10:53:34.9033333+00:00

    Hi Akbar Putra,

    Thanks for reaching out.

    The validation error suggests that your notification url is not able to respond to an endpoint validation request send by Microsoft.

    Your notification endpoint should have provision for reading the validation token from the query parameters and return it back immediately.

    Refer to the following link for more details

    https://learn.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0&tabs=http#notification-endpoint-validation

    To know how a sample notification endpoint handles this validation request, refer to the link below

    https://github.com/microsoftgraph/aspnetcore-webhooks-sample/blob/main/src/GraphWebhooks/Controllers/ListenController.cs

    Code from line 67 - 69 handles the validation request

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

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Sourabh Gupta 800 Reputation points Microsoft External Staff
    2024-05-04T11:00:42.67+00:00

    Hi Akbar Putra,

    Thanks for reaching out.

    The Validation error usually comes when Graph is not able to validate the notification end point mentioned in the request body,

    A request is sent by Microsoft in order to validate your end point and your endpoint must be capable of handling the validation request sent.

    Your endpoint should read the validation token sent as query parameter and return it back immediately.

    Kindly refer to the following link for more details

    https://learn.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0&tabs=http#notification-endpoint-validation

    To know about a sample webhook refer to the following link

    https://github.com/microsoftgraph/aspnetcore-webhooks-sample/blob/main/src/GraphWebhooks/Controllers/ListenController.cs

    Code from Line 67 -69 on above link is handling the validation request

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

    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.