sensorario
sensorario

Reputation: 21668

Microsoft Graph Rest API: how does "notification endpoint validation" works?

Reading the documentation I see that ... "The client must provide a response with the following characteristics within 10 seconds:"

The request I receive in the client is

/?validationToken=Validation%3a+Testing+client+application+reachability+for+subscription+Request-Id%3a+ef492401-75ec-4ac8-b87a-89d0b81ae977

So the response I give is

$responseCode = 200;
http_response_code($responseCode);
header('Content-type: text/plain');
echo $response = $_GET['validationToken'];

Translated, .. is:

Validation: Testing client application reachability for subscription Request-Id: ef492401-75ec-4ac8-b87a-89d0b81ae977

Why I am receiving this response?

< HTTP/1.1 400
< {
<     "error": {
<         "code": "InvalidRequest",
<         "message": "Subscription validation request failed. Must respond with 200 OK to this request.",
<         "innerError": {
<             "request-id": "ef492401-75ec-4ac8-b87a-89d0b81ae977",
<             "date": "2020-02-04T14:50:35"
<         }
<     }
< }

Upvotes: 1

Views: 713

Answers (1)

sensorario
sensorario

Reputation: 21668

The problem is here:

$request["notificationUrl"] = $conf['NotificationURL'];
$request["lifecycleNotificationUrl"] = "https://webhook.azurewebsites.net/api/lifecycleNotifications";

The second URL in configuration not exists. If called, return 400. Right configuration should be:

$request["notificationUrl"] = $conf['NotificationURL'];
$request["lifecycleNotificationUrl"] = $conf['NotificationURL'];

That solve the problem.

Upvotes: 0

Related Questions