Azure Microsoft Graph API - Subscription - validation request failed

Leo Lee 11 Reputation points
2020-06-23T14:46:36.8+00:00

I try to set up a notification for changes in Azure user data (https://learn.microsoft.com/en-us/graph/api/subscription-post-subscriptions?view=graph-rest-1.0&tabs=http)

Post request from Azure:

validationToken :Validation: Testing client application reachability for subscription Request-Id: 10b2280a-8ddf-4c1b-954b-451b0bb4e101

Is it a correct validationToken?

I try response with this validationToken (Validation: Testing client application reachability for subscription Request-Id: 10b2280a-8ddf-4c1b-954b-451b0bb4e101) and set 200 (OK) status code, The content type as text/plain. And i got the error -- Subscription validation request failed. Response must exactly match validationToken query parameter.

Microsoft Security Microsoft Entra Microsoft Entra ID
{count} vote

1 answer

Sort by: Most helpful
  1. Martin Bullman 26 Reputation points
    2020-07-27T11:28:46.603+00:00

    For the last week or so I was encountering the same issue when trying to create a subscription utilising the MS graph API.

    The following stack overflow thread helped me resolve the issue: https://stackoverflow.com/questions/53857198/notification-endpoint-validation-not-working-with-laravel-endpoint

    Basically I was sending back the validation token but my PHP framework was adding a new line character in the response body prior to the validation token being added. This meant MS Graph would always fail to validate my notification endpoint.

    Adding ob_clean() before returning the token resolved the issue for me.

    Hope it can help someone else out here!

    5 people found this answer helpful.

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.