Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional...

18
Webhooks in SharePoint Online MATT MAHER

Transcript of Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional...

Page 1: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Webhooks in

SharePoint OnlineMATT MAHER

Page 2: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

About Netwoven

Microsoft gold partner

Enterprise Content collaboration

Customer relationship management

Cloud productivity and development

Since 2001

Page 3: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Agenda

What are Webhooks

Who uses Webhooks

How webhooks are implemented in SharePoint

Demos

Advantages/Disadvantages

Page 4: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

What are webhooks?

A pattern that allows for event driven notification

Uses a push not pull concept

Supported in most modern platforms

SharePoint Implementation

Still in preview for SharePoint Online

Preview only supports Lists and Libraries

No official plans for an on-prem feature pack

Page 5: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

What are the alternatives within

SharePoint?

Remote Event Receivers

Workflows

Flow

RSS feeds

Email Alerts

CSOM Change log

Page 6: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Webhooks vs Traditional API

Client

SharePoint

Did anything change?

Nope

Did anything change?

Nope

Did anything change?

Nope

Did anything

change?

Nope

Did anything change?

Nope

Did

anything change?

Yes, Item 5

Please give me details on

Item 5Details for Item 5

Client

SharePoint

Your itemchanged

Please give me details on the change

Details for Item 5

Webhooks

Traditional API

Page 7: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Who uses webhooks?

Page 8: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Subscribe

HTTP/ 200 OK

{GUID}

SharePoint

Online

POST /_api/web/lists('list-id')/subscriptions

Your application

POST https://{your host}/your/webhook/service ?validationtoken={GUID}

WebHooknotification

endpoint

HTTP/ 201 CreatedYour application

{

"resource":"https://netwoveninc.sharepoint.com/_api/web/Lists/getbytitle('Documents') ",

“notificationUrl":"http://spsaturday.westus.cloudapp.azure.com",

"expirationDateTime":"2016-12-02T00:00:00+00:00"

}

{ "id": "a8e6d5e6-9f7f-497a-b97f-8ffe8f559dc7",

"expirationDateTime": "2016-12-27T16:17:57Z",

"notificationUrl": " http://spsaturday.westus.cloudapp.azure.com ","resource": “{list or library id}“

}

https://doc.co/Jwbh8r

Page 9: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Webhook Subscribe - Demo

Page 10: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Event notification in action

HTTP/ 200 OK

SharePoint

Online

WebHook notification

endpoint

POST https://{your host}/your/webhook/service

{"value":[

{

"subscriptionId":"91779246-afe9-4525-b122-6c199ae89211","clientState":"00000000-0000-0000-0000-000000000000",

"expirationDateTime":"2016-04-30T17:27:00.0000000Z","resource":"b9f6f714-9df8-470b-b22e-653855e1c181",

"tenantId":"00000000-0000-0000-0000-000000000000",

"siteUrl":"/","webId":"dbc5a806-e4d4-46e5-951c-6344d70b62fa"

}]

}

https://doc.co/Jwbh8r

Page 11: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Webhook Notification - Demo

Page 12: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Webhooks Advantages

Simple subscription and notification

Retry ability

Support delete events

Industry standard approach to notifications

In line with modern development stack of SPFx

Page 13: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Webhooks Disadvantages

6 month max expiration

Bare minimum information from SPO

Only Lists and Libraries are supported in SPO preview

Acknowledgement must be received quickly

May take upwards of 5 minutes to receive the notification

No synchronous events from SPO

Subscriptions and notifications go over the same URL

Page 14: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Webhooks Best Practice

Always implement an asynchronous process

Your App should update its subscriptions on a timed interval

Keep limited number of event subscriptions to minimize http requests to server

Log processed events to avoid duplicate event processing

Webhook notification acknowledgement has to be within 5 sec

BPM engines should still be used for more complex processes

Webhooks to replace your Nintex or SharePoint workflows

Page 15: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Webhook client notification - Demo

Page 16: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Resources

Video: https://dev.office.com/blogs/introducing-sharepoint-

webhooks

MSDN Details:

https://dev.office.com/sharepoint/docs/apis/webhooks/overview-

sharepoint-webhooks

Webhook events:

https://dev.office.com/sharepoint/docs/apis/webhooks/lists/overvie

w-sharepoint-list-webhooks

Github sample: https://github.com/SharePoint/sp-dev-

samples/tree/master/Samples/WebHooks.Nodejs

Page 17: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

Questions?

Page 18: Webhooks in SharePoint Online - Netwoven · PDF fileCSOM Change log. Webhooks vs Traditional API Client SharePoint Did anything ... SharePoint Online POST /_api/web/lists('list-id')/subscriptions

THANK YOU