Webhook Success Key #6: Use SharePoint REST to Get Webhook Information
John E. Huschka, January 25, 2018
Azure Functions — Internet cloud based custom code for SharePoint and Office 365.
SharePoint Webhooks — Connections that allow us to attach custom code to SharePoint that is called when events occur.
SharePoint REST API — A way to programmatically interact with SharePoint using standard web technology.
PowerShell — a command-line ("behind the scenes") Microsoft task automation tool used to administer SharePoint and Office 365.
This post is part of our blog series and demonstration code on achieving webhook success.
Sometimes you just need to get basic information about your webhooks, and SharePoint REST can be helpful for this.
For example, you can get details about all subscriptions associated with a list by adding a “subscriptions” qualifier to your REST list retrieval:
There are six pieces of information returned about the webhook subscription:
clientState: A string passed back to webhook handler all notifications. You can use this for validating notifications, tagging different subscriptions, or other reasons.
expirationDateTime: The expiration date for the webhook subscription.
id: A unique identifier assigned by SharePoint to the webhook subscription.
notificationUrl: The endpoint of the webhook handler that will be called by SharePoint.
resource: The SharePoint id of the object (i.e., list) to which the webhook subscription is attached.
resourceData: We have not seen this populated for SharePoint webhooks.
See Get subscriptions for additional information.
Also note that there are REST API calls available to create a new subscription, update a subscription, and to delete a subscription.
REST can be very helpful for getting information, but creating and modifying objects can be more work. Therefore, in our implementation, we have built an AddWebHookSubscription PowerShell script using Microsoft's PnP technology to create a new subscription:
SharePoint's REST API is a great tool for getting basic information about your webhooks, giving you important visibility into its existence and definition.
We at Collaboration Foundry are experts in SharePoint and Office 365. If you need assistance, we can help.
Contact us.
Also, don't forget to take a look at our
blog for more helpful tips and techniques.