Specific folder monitoring through webhook/subscription

S Kumar 21 Reputation points
2021-01-11T15:11:57.447+00:00

We have an application where we want to monitor a certain folder on SharePoint for changes using our application.
Change can be either file created or updated.
The folder that I want to monitor is named “shivamtest” which is inside a site “Connect” under the list “Shared Documents”.
Sample URL: https://*****.sharepoint.com/:f:/r/sites/Connect/Shared%20Documents/shivamtest

Note: we do not want to monitor either or list as they can have a large number of changes. We want to monitor only the specific folder.

Sample Folders location:

  1. https://*****.sharepoint.com/:f:/r/sites/Connect/Shared%20Documents/shivamtest
  2. https://*****.sharepoint.com/:f:/r/sites/Connect/Shared%20Documents/folder1/shivamtest
  3. https://*****.sharepoint.com/:f:/r/sites/Connect/Shared%20Documents/folder1/folder2/shivamtest
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,687 questions
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-01-12T07:55:38.433+00:00

    Hi @S Kumar ,

    We can only add webhooks to list level. So if there is any changes to the list, the application would be notified.

    And accroding to the documentation: https://learn.microsoft.com/en-us/sharepoint/dev/apis/webhooks/overview-sharepoint-webhooks#receiving-notifications

    The notification doesn't include any information about the changes that triggered it. Your application is expected to use the GetChanges API on the list to query the collection of changes from the change log and store the change token value for any subsequent calls when the application is notified.

    So to monitor specific folder, you need to use CSOM to get the entire changes in the list. Thus you could get the list item ID, with the list item ID you could get your file url. You could log the infomation of the file if it is in this specific folder.

    To get the changes of the list with webhookNotification , please refer to this article: https://social.technet.microsoft.com/wiki/contents/articles/38062.sharepoint-online-simulate-sharepoint-timer-jobs-and-event-receivers-using-azure-functions-and-sharepoint-webhooks.aspx#SharePoint_Webhooks_as_Event_Receivers


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful