I'm having trouble registering webhooks on document libraries using the /subscriptions endpoint.
When I use ngrok as the noticafication URL on my local environment, I am able to create the webhooks and listen to events successfully. However, after deploying to the dev environment and using an AWS API gateway (public)endpoint as a notification URL, I get the following error message:
Failed to validate the notification URL 'https:/***********/webhook/sharepoint'
Interestingly, when I hit the same API from Postman, it works fine. The endpoint is active and returns the validation token in less than 5 seconds.
I also tested the endpoints using the SSL server test tool and confirmed the endpoint is set to TLS 1.2.
What else could be the potential issue here?
I had a similar problem. Only on the Azure platform (WebApi .NET6).
The tutorial example (Azure Function) worked. But when I flipped it to WebApi I got a validation error.
It helped me first: MS Documentation
I found that the Content-Type is not being sent.
When I tried a request through Postman without a Content-Type, I got a 415 Unsupported Media Type from my WebApi.
I turned on web server logging in Azure. I ran the webhook registration (Add-PnPWebhookSubsciption). And I got the same error.
And that was the point. I modified the WebApi method to not have any [FromBody]/[FromQuery] input parameters and parsed them directly in the method body.
Registration was successful.
The error may not be the same, but this procedure may be helpful in finding the cause.
[AllowAnonymous]
[HttpPost]
[Route("webhookRequest")]
public async Task<IActionResult> WebhookRequest()
{
string validationToken = Request.Query["validationtoken"];
if (validationToken != null)
{
return (ActionResult)new OkObjectResult(validationToken);
}
string requestBody = await new StreamReader(Request.Body).ReadToEndAsync();
var data = JsonConvert.DeserializeObject<Response<Notification>>(requestBody);
// ....
}