I ran into the same problem with my endpoint and ended up putting a proxy in between so I could see if it was being called. It turned out mine was due to a 405
response from my service stating that the content-type text/plain
was not supported (my service was wired up to accept application/json
). Once I updated my endpoint to explicitly allow text/plain
as well, the subscription succeeded. I'm using Java and the Micronaut framework, but it may be a similar situation with your stack.
GraphError: Subscription validation request failed. Notification endpoint must respond with 200 OK to validation request.
I've been working on implementing Microsoft Graph webhook subscriptions in my application, and I've run into an issue with subscription validation. Whenever I attempt to validate the subscription, I receive the following error message:
GraphError: Subscription validation request failed. Notification endpoint must respond with 200 OK to validation request.
Here's a snippet of my code that handles the validation request:
@Post('event')
async eventWebhook(@Req() req, @Res() res) {
if (req.query && req.query.validationToken) {
res.set('Content-Type', 'text/plain');
res.send(200, req.query.validationToken);
return;
}
//... other logics to handle events
}
Additionally, I've used the official Postman collection provided by Microsoft to simulate the validation request, and it appears to work correctly. Here's the Postman request and response:
Postman Request:
curl --location --request POST 'api.com/event?validationToken=somethin'
Postman Response:
200 OK | 641 ms | 312 B
body : somethin
However, when I run my application on the server and attempt to set up a subscription through Microsoft Graph, I consistently encounter the validation error mentioned above.
I've verified the following:
The endpoint URL matches exactly with what I've specified in the subscription setup.
There are no network or firewall issues; the server is publicly accessible.
Middleware and routing do not interfere with the validation request.
There are no unexpected headers in the response.
The server configuration for handling POST requests is correct.
I'm unsure why the validation request fails in my application but works with Postman. Can anyone
offer guidance on what could be causing this issue or suggest potential solutions?
1 answer
Sort by: Most helpful
-
Chris Jones 0 Reputation points
2024-02-09T17:40:04.4933333+00:00