Failed To Validate The Notification URL SharePoint Webhook Azure Function Endpoint

In this Azure tutorial, we will discuss how to fix the error Failed To Validate The Notification URL SharePoint Webhook Azure Function Endpoint, which I got while trying to subscribe to Azure Function to the SharePoint List with Webhook for the Azure Function Endpoint URL.

Failed To Validate The Notification URL SharePoint Webhook Azure Function EndPoint

Recently, I was working for a requirement where I had to update the Sentiment score in the SharePoint List using the Azure Text Analytics API. As part of the requirement, I have created the below stuffs.

  • An Azure Text Analytics service in the Azure Portal.
  • Created an Azure Function App (.NET Core) in the Azure Portal.
  • I have also Created an HTTP triggered Azure Function using Visual Studio 2019 and deployed to Azure to the created Azure Function App.
  • Created a SharePoint custom list in my SharePoint online Site with the required columns.

Now My Azure Function should respond to the SharePoint Webhook. So I was using the PowerShell SharePoint PnP cmdlets to interact with the Azure Function EndPoint URL.

Below was the PowerShell SharePoint PnP cmdlets that I was using here

PS C:\WINDOWS\system32> Connect-PnPOnline -Url https://tsinfo.sharepoint.com/sites/Raju/
Add-PnPWebhookSubscription -List SentimentList -NotificationUrl https://sentimentfunctionapp.azurewebsites.net

You can able to see below after executing the above cmdlets, we got the below error

Failed To Validate The Notification URL SharePoint Webhook Azure Function Endpoint

The complete error message was as below

Add-PnPWebhookSubscription : {“odata.error”:{“code”:”-1,
System.InvalidOperationException”,”message”:{“lang”:”en-US”,”value”:”Failed to
validate the notification URL ‘https://sentimentfunctionapp.azurewebsites.net’.”}}}
At line:2 char:1

  • Add-PnPWebhookSubscription -List SentimentList -NotificationUrl https …
  • ~~~~~~~~~~~~~~~~~
    • CategoryInfo : WriteError: (:) [Add-PnPWebhookSubscription], Exception
    • FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Webhooks.Ad
      dWebhookSubscription

Failed To Validate The Notification URL SharePoint Webhook Azure Function Endpoint [Solved]

To fix this issue, What I have done is wrong, I was using the Azure Function App Endpoint URL, so only I was getting the error and SharePoint List Webhook fails to validate when using the Azure Function endpoint.

Now we need to follow the below steps to fix this issue.

Log in to the Azure Portal (https://portal.azure.com/)

Navigate to the Azure Function App and then click on the Functions from the left navigation. Now you can able to see the list of Azure Functions inside your Azure Function App. Click on the one that you want to interact with SharePoint.

On the Azure Function page, click on the Code + Test link from the left navigation and then click on the Get Function URL button to copy the Azure Function URL. Click on the copy button as highlighted below to copy the Azure Function URL.

Failed to validate notification URL

The Azure Function URL will look like below

https://sentimentfunctionapp.azurewebsites.net/api/FunctionSentiment?code=X7jt8XeMGK0fRCG2uJeC2nj0ewr8qqA52P4rkg7WTdglgf3RmqlIYQ==

Now the complete PowerShell SharePoint PnP cmdlets is as below

PS C:\WINDOWS\system32> Connect-PnPOnline -Url https://tsinfo.sharepoint.com/sites/Raju/
Add-PnPWebhookSubscription -List SentimentList -NotificationUrl https://sentimentfunctionapp.azurewebsites.net/api/FunctionSentiment?code=X7jt8XeMGK0fRCG2uJeC2nj0ewr8qqA52P4rkg7WTdglgf3RmqlIYQ==

You can able to see below, we got the expected Output without any issues this time

SharePoint List Webhook fails to validate when using Azure Function endpoint

This is how you can fix the error Failed To Validate The Notification URL SharePoint Webhook Azure Function Endpoint.

You may also like following the below articles

Wrapping Up

Well, In this article, We have discussed how to fix the error Failed To Validate The Notification URL SharePoint Webhook Azure Function Endpoint or Failed to validate notification URL. Hope this will help you to fix your issue as well !!!