1

I have an application that takes in SharePoint webhook notifications. Currently, the format of the site URLs is: /sites/<hub-site>/<sub-site>. Each of these sub sites has 3 libraries. I have added a webhook subscription using PnP PowerShell to each of these libraries.

The problem I am facing is the resulting siteUrl field in the webhook notification is not the right URL, only supplying: /sites/<hub-site> without the subsite portion of the URL. This ends up as an exception because no libraries exist on that path.

I use the command Add-PnPWebhookSubscription -List <list> -NotificationUrl <url> -ClientState <list-id> to add my webhooks.

Has anyone faced this issue before?

{ "value": [ { "subscriptionId": "<subscription-id>", "clientState": "<list-id>", "expirationDateTime": "2025-12-12T16:13:07.5160000Z", "resource": "<list-id>", "tenantId": "<tenant-id>", "siteUrl": "/sites/<hub-site-name>", // no sub site "webId": "<web-id>" } ] } 

Update: Solved! I was able to use the webId field to find the individual subsite within the supplied hub site URL.

0

1 Answer 1

2

In SharePoint speak, site collections are site and sub sites are called web. The webId will give you the ID of the sub site that the notification is coming from.

for more information about the response structure see https://learn.microsoft.com/en-us/sharepoint/dev/apis/webhooks/overview-sharepoint-webhooks

2
  • Thank you! I was able to create a context using the hub site URL and use context.Web.Webs, searching for the right web using the WebId. I then used web.RootFolder.ServerRelativeUrl to get the actual site Url, and used that as the context. Strange that the Site URL from the webhook isn't accurate to the subsite the list is held in though. Commented Jun 18 at 13:34
  • Thanks for the feedback and glad you got it to work. The site url doesn't include the subsite because it's the site collection (or site) url and not the subsite (the web) url. Commented Jun 23 at 7:27

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.