SlideShare ist ein Scribd-Unternehmen logo
1 von 41
Elio Struyf | Trainer @ U2U – MVP | June 24th, 2017
Getting notified by SharePoint with the webHook
functionality
Thanks to the Sponsors!
#SPSLondon - @eliostruyf
What are WebHooks?
#SPSLondon - @eliostruyf
What are WebHooks?
• Event driven notifications AKA callbacks from the web
• Universal model used by many services: GitHub, Slack, MailChimp, …
• Pushing mechanism  asynchronous!
• Implemented in various Office 365 Services
• Microsoft Graph
• Connectors
• SharePoint
#SPSLondon - @eliostruyf
WebHooks in SPO went GA
in January 2017
#SPSLondon - @eliostruyf
Where can you use them?
• SharePoint
• List
• Libraries
• Microsoft Graph
• Messages, events, contacts, conversations in groups, OneDrive root items
#SPSLondon - @eliostruyf
The good and the bad
• WebHooks are asynchronous mechanism
• Retry mechanism
• 5 times with a delay of 5 minutes
• More secure, no event information is passed
• No support for event-ing events  only RER can be used
• Add-ing, update-ing, delete-ing
• Requires some setup, but once done, it is easy to maintain
#SPSLondon - @eliostruyf
Remote event receivers vs WebHooks
Remote event receivers
• Synchronous (-ing) and/or async (-ed)
• One request
• One change = one request
• Changes are inside the request body
• 2 minutes to respond
• Indefinitely
• One try
WebHooks
• Async only
• Retry logic: 5 times
• Batched requests
• Only notification  more secure
• 5 seconds to respond
• Needs subscription renewal
• When it fails, you can try again later
Both use the same base principle: call an external URI when something happens
#SPSLondon - @eliostruyf
How to start using
WebHooks?
#SPSLondon - @eliostruyf
By subscribing to a WebHook!
Notification service
1. Create a subscription
4. SharePoint responds with subscription info
#SPSLondon - @eliostruyf
Important things about subscribing
Subscribing: POST - /_api/web/lists/getbytitle('Title')/subscriptions
{
"resource": "https://tenant.sharepoint.com/sites/site/_api/web/lists/getbytitle('Title')",
"notificationUrl": "Your notification service URL – HTTPS is required",
"expirationDateTime": "Date value - maximum 6 months",
"clientState": "String value for validation (optional)"
}
#SPSLondon - @eliostruyf
Important things about subscribing
SharePoint calls your notification service:
POST - https://notification-service?validationToken={random-guid}
Respond with:
Important: notification service needs to respond in < 5 seconds
Status: 200
Body: validationtoken
#SPSLondon - @eliostruyf
Important things about subscribing
When validation is done, SharePoint returns the subscription
information
#SPSLondon - @eliostruyf
Local development and testing:
ngrok - Secure tunnels to localhost
https://ngrok.com/
#SPSLondon - @eliostruyf
Demo
Subscribing to a WebHook
#SPSLondon - @eliostruyf
More about the notification
service
#SPSLondon - @eliostruyf
Notification service details
• You choose the technology: Web API, Node.js, …
• Respond in < 5 seconds and with status: 200-299 range
• Retry mechanism  5 times (5 minute in between)
• Not for the validation process
• Receives minimal information, just a message “something” happened
• Service has to gather the changes from SharePoint
#SPSLondon - @eliostruyf
Minimal notification information?
#SPSLondon - @eliostruyf
This is what you will receive
{
"value": [
{
"subscriptionId":"2e7f9cd7-5cdb-4d57-b4d5-edc083202378",
"clientState":null,
"expirationDateTime":"2017-08-16T10:38:54.3440000Z",
"resource":"465b36fc-e778-4047-8425-3f906497dfc3",
"tenantId":"9fee8694-d491-4e3e-b10b-a81ee76dfad9",
"siteUrl":"/sites/Webhooks",
"webId":"e363e4e9-0161-495f-a652-15c618e2e963“
}]
}
#SPSLondon - @eliostruyf
How do I know what happened?
• SPList.GetChanges method
• POST - `/_api/web/lists(guid'${resource}')/getchanges`
• Specify a change query + change token
{
"Item": true,
"Add": true,
"Update": true,
"DeleteObject": true,
"Restore": true,
"ChangeTokenStart": {
"StringValue": "1;3;465b36fc-e778-4047-8425-3f906497dfc3;636307008298500000;60877869"
}
}
ChangeQuery properties: http://elst.es/2rib2q7
#SPSLondon - @eliostruyf
Anatomy of the change token
1;3;465b36fc-e778-4047-8425-3f906497dfc3;636307008298500000;60877869
Version information (currently always 1)
Scope of the change. 3 = List & library changes.
Resource ID, can be retrieved from the subscription notification
Timestamp in ticks
Change number
in the event
cache table. You
can start with -1.
#SPSLondon - @eliostruyf
Using the change token
• Using GetChanges without ChangeToken would return everything
• By specifying a change token, you control what you need
#SPSLondon - @eliostruyf
Things to know about the change token
• First time, create it yourself (ex.: get all changes of the last hour)
• Per GetChanges request, you get the latest change token
• Store the latest change token, use it for the next call
{
"ChangeToken": {
"StringValue":"1;3;465b36fc-e778-4047-8425-3f906497dfc3;636307074435230000;60879219"
},
"ChangeType": 2,
"SiteId": "1432d309-9f6a-4dae-8d35-532dec332b86",
"ItemId": 3,
…
}
#SPSLondon - @eliostruyf
GetChanges response value
• Notice the ChangeType, it is an enumeration
• 1 = added, 2 = updated, 3 = deleted
{
"ChangeToken": {
"StringValue":"1;3;465b36fc-e778-4047-8425-3f906497dfc3;636307074435230000;60879219"
},
"ChangeType": 2,
"SiteId": "1432d309-9f6a-4dae-8d35-532dec332b86",
"ItemId": 3,
"ServerRelativeUrl":"",
…
"WebId":"e363e4e9-0161-495f-a652-15c618e2e963"
}
More information about the ChangeTypes - http://elst.es/2ruAfKn
#SPSLondon - @eliostruyf
Supported event types
• Added
• Updated
• Deleted
• CheckedOut
• CheckedIn
• UncheckedOut
• AttachmentAdded
• AttachmentDeleted
• FileMoved
• VersionDeleted
• FileConverted
#SPSLondon - @eliostruyf
Creating your notification
service
#SPSLondon - @eliostruyf
Tokens, all about the OAuth tokens
• Azure AD app registration
• Generate a certificate
• SharePoint requires access tokens with appidacr property set to 2
• Application Authentication Context Class Reference
• 0 = Public client
• 1 = Identified by a client id and secret
• 2 = Identified by a certificate
Azure AD application manifest
Store this in a separate file (privatekey.pem)
Fingerprint is also require to get the access token
#SPSLondon - @eliostruyf
public getAppOnlyAccessToken(config: IConfig): Promise<any> {
return new Promise((resolve, reject) => {
const certificate = fs.readFileSync(path.join(__dirname, 'privatekey.pem'), { encoding : 'utf8'});
const authContext = new adal.AuthenticationContext(config.adalConfig.authority);
authContext.acquireTokenWithClientCertificate(config.adalConfig.resource, config.adalConfig.clientID, certificate,
config.adalConfig.fingerPrint, (err, tokenRes) => {
if (err) {
reject(err);
}
const accesstoken = tokenRes.accessToken;
resolve(accesstoken);
});
});
}
Get an access token via a certificate and
private key with ADAL for JS
#SPSLondon - @eliostruyf
Important APIs
• Retrieve all list / library subscriptions
GET - /_api/web/lists/getbytitle('ListTitle')/subscriptions
• Update a subscription
PATCH - /_api/web/lists/getbytitle('ListTitle')/subscriptions('${subId}')
Body: { "expirationDateTime": "New expiration date" }
• Delete a subscription
DELETE - /_api/web/lists/getbytitle('ListTitle')/subscriptions('${subId}')
#SPSLondon - @eliostruyf
Demo
Sample application
#SPSLondon - @eliostruyf
A real life setup and configuration
SPO config page
HTTP Triggered function
Queue triggered function
1. Subscribe 2. Validate
3. Trigger change
4. Notify service
5. Put notification message on a queue6. Respond with 200
Use the page to:
- Check subscriptions
- Update subscriptions
- Delete subscriptions
7. Trigger another Azure function that will do change handling
8. Retrieve latest change token10. Store latest change token
#SPSLondon - @eliostruyf
Demo
SPFx + Azure Functions
#SPSLondon - @eliostruyf
Recap
• Notification service has to respond in < 5 seconds
• Retry mechanism  5 times (5 minute delay)
• Not for the validation process
• Subscription expiration date: 6 months
• Create a check or renewal process in your subscription processor
• You need to ask for the changes that happened  minimal
information is send
• Get the changes only what you are interested in
• No synchronous events for SPO  event-ing events
Questions?
Office Servers & Services MVP
Azure / Office 365 / SharePoint
@eliostruyf
www.eliostruyf.com
info@estruyf.be
Elio Struyf
Lead trainer and architect
#SPSLondon - @eliostruyf
Resources
Certificate creation process with makecert - http://elst.es/2rhveZc
Keycred GitHub - http://elst.es/2pW77vm
All about the Change token - http://elst.es/2runG1M
ChangeType enumeration - http://elst.es/2ruAfKn
ChangeQuery properties - http://elst.es/2rib2q7
C# Sample application - http://elst.es/2qUYg0M
Node.js / TypeScript sample application - http://elst.es/2qVpTqT or http://elst.es/2cycM82
SharePoint List WebHooks docs - http://elst.es/2qwl1as - http://elst.es/2quVjD0

Weitere ähnliche Inhalte

Was ist angesagt?

Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server PushReal Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server PushLucas Jellema
 
Spring Cloud Gateway
Spring Cloud GatewaySpring Cloud Gateway
Spring Cloud GatewayVMware Tanzu
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC ServiceJessie Barnett
 
Top 10 New SharePoint Online Features
Top 10 New SharePoint Online FeaturesTop 10 New SharePoint Online Features
Top 10 New SharePoint Online FeaturesOffice
 
SSL Communication and Mutual Authentication
SSL Communication and Mutual AuthenticationSSL Communication and Mutual Authentication
SSL Communication and Mutual AuthenticationCleo
 
Javascript under the hood 2
Javascript under the hood 2Javascript under the hood 2
Javascript under the hood 2Thang Tran Duc
 
Melbourne UG Presentation - UI Flow for Power Automate
Melbourne UG Presentation - UI Flow for Power AutomateMelbourne UG Presentation - UI Flow for Power Automate
Melbourne UG Presentation - UI Flow for Power AutomateAndre Margono
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debeziumKasun Don
 
Microservices und das Entity Control Boundary Pattern
Microservices und das Entity Control Boundary PatternMicroservices und das Entity Control Boundary Pattern
Microservices und das Entity Control Boundary PatternBrockhaus Consulting GmbH
 
Building Modern Intranets With SharePoint & Teams
Building Modern Intranets With SharePoint & TeamsBuilding Modern Intranets With SharePoint & Teams
Building Modern Intranets With SharePoint & TeamsJoy Apple
 
A Brief History of Microsoft Exchange Server
A Brief History of Microsoft Exchange ServerA Brief History of Microsoft Exchange Server
A Brief History of Microsoft Exchange Serverbedekarpm
 
Soap web service
Soap web serviceSoap web service
Soap web serviceNITT, KAMK
 
OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater Apigee | Google Cloud
 
Building Pinterest Real-Time Ads Platform Using Kafka Streams
Building Pinterest Real-Time Ads Platform Using Kafka Streams Building Pinterest Real-Time Ads Platform Using Kafka Streams
Building Pinterest Real-Time Ads Platform Using Kafka Streams confluent
 
Building Event Driven (Micro)services with Apache Kafka
Building Event Driven (Micro)services with Apache KafkaBuilding Event Driven (Micro)services with Apache Kafka
Building Event Driven (Micro)services with Apache KafkaGuido Schmutz
 
Power Automate/ Flow patterns tips and tricks after 3 years with Doctor Flow
Power Automate/ Flow patterns tips and tricks after 3 years with Doctor FlowPower Automate/ Flow patterns tips and tricks after 3 years with Doctor Flow
Power Automate/ Flow patterns tips and tricks after 3 years with Doctor Flowserge luca
 
Postman: An Introduction for Developers
Postman: An Introduction for DevelopersPostman: An Introduction for Developers
Postman: An Introduction for DevelopersPostman
 

Was ist angesagt? (20)

Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server PushReal Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
 
Spring Cloud Gateway
Spring Cloud GatewaySpring Cloud Gateway
Spring Cloud Gateway
 
Building your First gRPC Service
Building your First gRPC ServiceBuilding your First gRPC Service
Building your First gRPC Service
 
Top 10 New SharePoint Online Features
Top 10 New SharePoint Online FeaturesTop 10 New SharePoint Online Features
Top 10 New SharePoint Online Features
 
SSL Communication and Mutual Authentication
SSL Communication and Mutual AuthenticationSSL Communication and Mutual Authentication
SSL Communication and Mutual Authentication
 
Javascript under the hood 2
Javascript under the hood 2Javascript under the hood 2
Javascript under the hood 2
 
Melbourne UG Presentation - UI Flow for Power Automate
Melbourne UG Presentation - UI Flow for Power AutomateMelbourne UG Presentation - UI Flow for Power Automate
Melbourne UG Presentation - UI Flow for Power Automate
 
Kafka Connect - debezium
Kafka Connect - debeziumKafka Connect - debezium
Kafka Connect - debezium
 
Microservices und das Entity Control Boundary Pattern
Microservices und das Entity Control Boundary PatternMicroservices und das Entity Control Boundary Pattern
Microservices und das Entity Control Boundary Pattern
 
Building Modern Intranets With SharePoint & Teams
Building Modern Intranets With SharePoint & TeamsBuilding Modern Intranets With SharePoint & Teams
Building Modern Intranets With SharePoint & Teams
 
A Brief History of Microsoft Exchange Server
A Brief History of Microsoft Exchange ServerA Brief History of Microsoft Exchange Server
A Brief History of Microsoft Exchange Server
 
Soap web service
Soap web serviceSoap web service
Soap web service
 
OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater OAuth - Don’t Throw the Baby Out with the Bathwater
OAuth - Don’t Throw the Baby Out with the Bathwater
 
Building Pinterest Real-Time Ads Platform Using Kafka Streams
Building Pinterest Real-Time Ads Platform Using Kafka Streams Building Pinterest Real-Time Ads Platform Using Kafka Streams
Building Pinterest Real-Time Ads Platform Using Kafka Streams
 
NiFi 시작하기
NiFi 시작하기NiFi 시작하기
NiFi 시작하기
 
Building Event Driven (Micro)services with Apache Kafka
Building Event Driven (Micro)services with Apache KafkaBuilding Event Driven (Micro)services with Apache Kafka
Building Event Driven (Micro)services with Apache Kafka
 
Power Automate/ Flow patterns tips and tricks after 3 years with Doctor Flow
Power Automate/ Flow patterns tips and tricks after 3 years with Doctor FlowPower Automate/ Flow patterns tips and tricks after 3 years with Doctor Flow
Power Automate/ Flow patterns tips and tricks after 3 years with Doctor Flow
 
Postman: An Introduction for Developers
Postman: An Introduction for DevelopersPostman: An Introduction for Developers
Postman: An Introduction for Developers
 
Implementing Open Banking with ForgeRock
Implementing Open Banking with ForgeRockImplementing Open Banking with ForgeRock
Implementing Open Banking with ForgeRock
 
Sharepoint
SharepointSharepoint
Sharepoint
 

Ähnlich wie Getting notified by SharePoint with the webhook functionality

SPSNL17 - Getting notified by SharePoint with the webhook functionality - Eli...
SPSNL17 - Getting notified by SharePoint with the webhook functionality - Eli...SPSNL17 - Getting notified by SharePoint with the webhook functionality - Eli...
SPSNL17 - Getting notified by SharePoint with the webhook functionality - Eli...DIWUG
 
SharePoint 2013 REST APIs
SharePoint 2013 REST APIsSharePoint 2013 REST APIs
SharePoint 2013 REST APIsGiuseppe Marchi
 
Microservices and the Art of Taming the Dependency Hell Monster
Microservices and the Art of Taming the Dependency Hell MonsterMicroservices and the Art of Taming the Dependency Hell Monster
Microservices and the Art of Taming the Dependency Hell MonsterC4Media
 
Evolution of the REST API
Evolution of the REST APIEvolution of the REST API
Evolution of the REST APIJeremyOtt5
 
10 points to make a rogue SharePoint environment really, really secure..
10 points to make a rogue SharePoint environment really, really secure..10 points to make a rogue SharePoint environment really, really secure..
10 points to make a rogue SharePoint environment really, really secure..SharePoint Saturday New Jersey
 
Entwickler camp2012 how to connect your app to the activity stream with x_pages
Entwickler camp2012 how to connect your app to the activity stream with x_pagesEntwickler camp2012 how to connect your app to the activity stream with x_pages
Entwickler camp2012 how to connect your app to the activity stream with x_pagesFrank van der Linden
 
Foxtrot: Real time analytics
Foxtrot: Real time analyticsFoxtrot: Real time analytics
Foxtrot: Real time analyticsSantanu Sinha
 
Spring MVC to iOS and the REST
Spring MVC to iOS and the RESTSpring MVC to iOS and the REST
Spring MVC to iOS and the RESTRoy Clarkson
 
Develop IoT project with AirVantage M2M Cloud
Develop IoT project with AirVantage M2M CloudDevelop IoT project with AirVantage M2M Cloud
Develop IoT project with AirVantage M2M CloudCrystal Lam
 
Blockchain in the Food Supply Chain
Blockchain in the Food Supply ChainBlockchain in the Food Supply Chain
Blockchain in the Food Supply ChainPeter Kirchner
 
Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring UpdateGunnar Hillert
 
SPS Oslo 2018 - Office 365 User Onboarding
SPS Oslo 2018 - Office 365 User OnboardingSPS Oslo 2018 - Office 365 User Onboarding
SPS Oslo 2018 - Office 365 User OnboardingJimmy Hang
 
Externalizing Authorization in Micro Services world
Externalizing Authorization in Micro Services worldExternalizing Authorization in Micro Services world
Externalizing Authorization in Micro Services worldSitaraman Lakshminarayanan
 
SPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans SubscriptionsSPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans SubscriptionsChris Givens
 
OpenSocial and Mixi platform
OpenSocial and Mixi platformOpenSocial and Mixi platform
OpenSocial and Mixi platformPham Thinh
 
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013Kiril Iliev
 
Introduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and DevelopersIntroduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and DevelopersMichael Blumenthal (Microsoft MVP)
 
How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.Renzo Tomà
 

Ähnlich wie Getting notified by SharePoint with the webhook functionality (20)

SPSNL17 - Getting notified by SharePoint with the webhook functionality - Eli...
SPSNL17 - Getting notified by SharePoint with the webhook functionality - Eli...SPSNL17 - Getting notified by SharePoint with the webhook functionality - Eli...
SPSNL17 - Getting notified by SharePoint with the webhook functionality - Eli...
 
SharePoint 2013 REST APIs
SharePoint 2013 REST APIsSharePoint 2013 REST APIs
SharePoint 2013 REST APIs
 
PnP Monthly Community Call - April 2018
PnP Monthly Community Call - April 2018PnP Monthly Community Call - April 2018
PnP Monthly Community Call - April 2018
 
Microservices and the Art of Taming the Dependency Hell Monster
Microservices and the Art of Taming the Dependency Hell MonsterMicroservices and the Art of Taming the Dependency Hell Monster
Microservices and the Art of Taming the Dependency Hell Monster
 
Evolution of the REST API
Evolution of the REST APIEvolution of the REST API
Evolution of the REST API
 
10 points to make a rogue SharePoint environment really, really secure..
10 points to make a rogue SharePoint environment really, really secure..10 points to make a rogue SharePoint environment really, really secure..
10 points to make a rogue SharePoint environment really, really secure..
 
Entwickler camp2012 how to connect your app to the activity stream with x_pages
Entwickler camp2012 how to connect your app to the activity stream with x_pagesEntwickler camp2012 how to connect your app to the activity stream with x_pages
Entwickler camp2012 how to connect your app to the activity stream with x_pages
 
Foxtrot: Real time analytics
Foxtrot: Real time analyticsFoxtrot: Real time analytics
Foxtrot: Real time analytics
 
Spring MVC to iOS and the REST
Spring MVC to iOS and the RESTSpring MVC to iOS and the REST
Spring MVC to iOS and the REST
 
Develop IoT project with AirVantage M2M Cloud
Develop IoT project with AirVantage M2M CloudDevelop IoT project with AirVantage M2M Cloud
Develop IoT project with AirVantage M2M Cloud
 
Blockchain in the Food Supply Chain
Blockchain in the Food Supply ChainBlockchain in the Food Supply Chain
Blockchain in the Food Supply Chain
 
The Spring Update
The Spring UpdateThe Spring Update
The Spring Update
 
Ajug - The Spring Update
Ajug - The Spring UpdateAjug - The Spring Update
Ajug - The Spring Update
 
SPS Oslo 2018 - Office 365 User Onboarding
SPS Oslo 2018 - Office 365 User OnboardingSPS Oslo 2018 - Office 365 User Onboarding
SPS Oslo 2018 - Office 365 User Onboarding
 
Externalizing Authorization in Micro Services world
Externalizing Authorization in Micro Services worldExternalizing Authorization in Micro Services world
Externalizing Authorization in Micro Services world
 
SPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans SubscriptionsSPSRED - BCS, REST ans Subscriptions
SPSRED - BCS, REST ans Subscriptions
 
OpenSocial and Mixi platform
OpenSocial and Mixi platformOpenSocial and Mixi platform
OpenSocial and Mixi platform
 
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
jsSaturday - PhoneGap and jQuery Mobile for SharePoint 2013
 
Introduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and DevelopersIntroduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and Developers
 
How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.
 

Mehr von Elio Struyf

SPSBE - Improving your SharePoint search experience
SPSBE - Improving your SharePoint search experienceSPSBE - Improving your SharePoint search experience
SPSBE - Improving your SharePoint search experienceElio Struyf
 
Take your display template skills to the next level
Take your display template skills to the next levelTake your display template skills to the next level
Take your display template skills to the next levelElio Struyf
 
Farewell XSL, Welcome Display Templates SPSNL
Farewell XSL, Welcome Display Templates SPSNLFarewell XSL, Welcome Display Templates SPSNL
Farewell XSL, Welcome Display Templates SPSNLElio Struyf
 
Farewell XSL, Welcome Display Templates
Farewell XSL, Welcome Display TemplatesFarewell XSL, Welcome Display Templates
Farewell XSL, Welcome Display TemplatesElio Struyf
 
Biwug presenation-spsbe33
Biwug presenation-spsbe33Biwug presenation-spsbe33
Biwug presenation-spsbe33Elio Struyf
 
Introduction to XSLT SPSBE07
Introduction to XSLT SPSBE07Introduction to XSLT SPSBE07
Introduction to XSLT SPSBE07Elio Struyf
 

Mehr von Elio Struyf (6)

SPSBE - Improving your SharePoint search experience
SPSBE - Improving your SharePoint search experienceSPSBE - Improving your SharePoint search experience
SPSBE - Improving your SharePoint search experience
 
Take your display template skills to the next level
Take your display template skills to the next levelTake your display template skills to the next level
Take your display template skills to the next level
 
Farewell XSL, Welcome Display Templates SPSNL
Farewell XSL, Welcome Display Templates SPSNLFarewell XSL, Welcome Display Templates SPSNL
Farewell XSL, Welcome Display Templates SPSNL
 
Farewell XSL, Welcome Display Templates
Farewell XSL, Welcome Display TemplatesFarewell XSL, Welcome Display Templates
Farewell XSL, Welcome Display Templates
 
Biwug presenation-spsbe33
Biwug presenation-spsbe33Biwug presenation-spsbe33
Biwug presenation-spsbe33
 
Introduction to XSLT SPSBE07
Introduction to XSLT SPSBE07Introduction to XSLT SPSBE07
Introduction to XSLT SPSBE07
 

Kürzlich hochgeladen

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Kürzlich hochgeladen (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

Getting notified by SharePoint with the webhook functionality

  • 1. Elio Struyf | Trainer @ U2U – MVP | June 24th, 2017 Getting notified by SharePoint with the webHook functionality
  • 2. Thanks to the Sponsors!
  • 4. #SPSLondon - @eliostruyf What are WebHooks? • Event driven notifications AKA callbacks from the web • Universal model used by many services: GitHub, Slack, MailChimp, … • Pushing mechanism  asynchronous! • Implemented in various Office 365 Services • Microsoft Graph • Connectors • SharePoint
  • 5. #SPSLondon - @eliostruyf WebHooks in SPO went GA in January 2017
  • 6. #SPSLondon - @eliostruyf Where can you use them? • SharePoint • List • Libraries • Microsoft Graph • Messages, events, contacts, conversations in groups, OneDrive root items
  • 7. #SPSLondon - @eliostruyf The good and the bad • WebHooks are asynchronous mechanism • Retry mechanism • 5 times with a delay of 5 minutes • More secure, no event information is passed • No support for event-ing events  only RER can be used • Add-ing, update-ing, delete-ing • Requires some setup, but once done, it is easy to maintain
  • 8. #SPSLondon - @eliostruyf Remote event receivers vs WebHooks Remote event receivers • Synchronous (-ing) and/or async (-ed) • One request • One change = one request • Changes are inside the request body • 2 minutes to respond • Indefinitely • One try WebHooks • Async only • Retry logic: 5 times • Batched requests • Only notification  more secure • 5 seconds to respond • Needs subscription renewal • When it fails, you can try again later Both use the same base principle: call an external URI when something happens
  • 9. #SPSLondon - @eliostruyf How to start using WebHooks?
  • 10. #SPSLondon - @eliostruyf By subscribing to a WebHook! Notification service 1. Create a subscription 4. SharePoint responds with subscription info
  • 11. #SPSLondon - @eliostruyf Important things about subscribing Subscribing: POST - /_api/web/lists/getbytitle('Title')/subscriptions { "resource": "https://tenant.sharepoint.com/sites/site/_api/web/lists/getbytitle('Title')", "notificationUrl": "Your notification service URL – HTTPS is required", "expirationDateTime": "Date value - maximum 6 months", "clientState": "String value for validation (optional)" }
  • 12. #SPSLondon - @eliostruyf Important things about subscribing SharePoint calls your notification service: POST - https://notification-service?validationToken={random-guid} Respond with: Important: notification service needs to respond in < 5 seconds Status: 200 Body: validationtoken
  • 13. #SPSLondon - @eliostruyf Important things about subscribing When validation is done, SharePoint returns the subscription information
  • 14. #SPSLondon - @eliostruyf Local development and testing: ngrok - Secure tunnels to localhost https://ngrok.com/
  • 15.
  • 17. #SPSLondon - @eliostruyf More about the notification service
  • 18. #SPSLondon - @eliostruyf Notification service details • You choose the technology: Web API, Node.js, … • Respond in < 5 seconds and with status: 200-299 range • Retry mechanism  5 times (5 minute in between) • Not for the validation process • Receives minimal information, just a message “something” happened • Service has to gather the changes from SharePoint
  • 19. #SPSLondon - @eliostruyf Minimal notification information?
  • 20. #SPSLondon - @eliostruyf This is what you will receive { "value": [ { "subscriptionId":"2e7f9cd7-5cdb-4d57-b4d5-edc083202378", "clientState":null, "expirationDateTime":"2017-08-16T10:38:54.3440000Z", "resource":"465b36fc-e778-4047-8425-3f906497dfc3", "tenantId":"9fee8694-d491-4e3e-b10b-a81ee76dfad9", "siteUrl":"/sites/Webhooks", "webId":"e363e4e9-0161-495f-a652-15c618e2e963“ }] }
  • 21. #SPSLondon - @eliostruyf How do I know what happened? • SPList.GetChanges method • POST - `/_api/web/lists(guid'${resource}')/getchanges` • Specify a change query + change token { "Item": true, "Add": true, "Update": true, "DeleteObject": true, "Restore": true, "ChangeTokenStart": { "StringValue": "1;3;465b36fc-e778-4047-8425-3f906497dfc3;636307008298500000;60877869" } } ChangeQuery properties: http://elst.es/2rib2q7
  • 22. #SPSLondon - @eliostruyf Anatomy of the change token 1;3;465b36fc-e778-4047-8425-3f906497dfc3;636307008298500000;60877869 Version information (currently always 1) Scope of the change. 3 = List & library changes. Resource ID, can be retrieved from the subscription notification Timestamp in ticks Change number in the event cache table. You can start with -1.
  • 23. #SPSLondon - @eliostruyf Using the change token • Using GetChanges without ChangeToken would return everything • By specifying a change token, you control what you need
  • 24. #SPSLondon - @eliostruyf Things to know about the change token • First time, create it yourself (ex.: get all changes of the last hour) • Per GetChanges request, you get the latest change token • Store the latest change token, use it for the next call { "ChangeToken": { "StringValue":"1;3;465b36fc-e778-4047-8425-3f906497dfc3;636307074435230000;60879219" }, "ChangeType": 2, "SiteId": "1432d309-9f6a-4dae-8d35-532dec332b86", "ItemId": 3, … }
  • 25. #SPSLondon - @eliostruyf GetChanges response value • Notice the ChangeType, it is an enumeration • 1 = added, 2 = updated, 3 = deleted { "ChangeToken": { "StringValue":"1;3;465b36fc-e778-4047-8425-3f906497dfc3;636307074435230000;60879219" }, "ChangeType": 2, "SiteId": "1432d309-9f6a-4dae-8d35-532dec332b86", "ItemId": 3, "ServerRelativeUrl":"", … "WebId":"e363e4e9-0161-495f-a652-15c618e2e963" } More information about the ChangeTypes - http://elst.es/2ruAfKn
  • 26. #SPSLondon - @eliostruyf Supported event types • Added • Updated • Deleted • CheckedOut • CheckedIn • UncheckedOut • AttachmentAdded • AttachmentDeleted • FileMoved • VersionDeleted • FileConverted
  • 27. #SPSLondon - @eliostruyf Creating your notification service
  • 28.
  • 29.
  • 30. #SPSLondon - @eliostruyf Tokens, all about the OAuth tokens • Azure AD app registration • Generate a certificate • SharePoint requires access tokens with appidacr property set to 2 • Application Authentication Context Class Reference • 0 = Public client • 1 = Identified by a client id and secret • 2 = Identified by a certificate
  • 31. Azure AD application manifest Store this in a separate file (privatekey.pem) Fingerprint is also require to get the access token
  • 32.
  • 33. #SPSLondon - @eliostruyf public getAppOnlyAccessToken(config: IConfig): Promise<any> { return new Promise((resolve, reject) => { const certificate = fs.readFileSync(path.join(__dirname, 'privatekey.pem'), { encoding : 'utf8'}); const authContext = new adal.AuthenticationContext(config.adalConfig.authority); authContext.acquireTokenWithClientCertificate(config.adalConfig.resource, config.adalConfig.clientID, certificate, config.adalConfig.fingerPrint, (err, tokenRes) => { if (err) { reject(err); } const accesstoken = tokenRes.accessToken; resolve(accesstoken); }); }); } Get an access token via a certificate and private key with ADAL for JS
  • 34. #SPSLondon - @eliostruyf Important APIs • Retrieve all list / library subscriptions GET - /_api/web/lists/getbytitle('ListTitle')/subscriptions • Update a subscription PATCH - /_api/web/lists/getbytitle('ListTitle')/subscriptions('${subId}') Body: { "expirationDateTime": "New expiration date" } • Delete a subscription DELETE - /_api/web/lists/getbytitle('ListTitle')/subscriptions('${subId}')
  • 36. #SPSLondon - @eliostruyf A real life setup and configuration SPO config page HTTP Triggered function Queue triggered function 1. Subscribe 2. Validate 3. Trigger change 4. Notify service 5. Put notification message on a queue6. Respond with 200 Use the page to: - Check subscriptions - Update subscriptions - Delete subscriptions 7. Trigger another Azure function that will do change handling 8. Retrieve latest change token10. Store latest change token
  • 38. #SPSLondon - @eliostruyf Recap • Notification service has to respond in < 5 seconds • Retry mechanism  5 times (5 minute delay) • Not for the validation process • Subscription expiration date: 6 months • Create a check or renewal process in your subscription processor • You need to ask for the changes that happened  minimal information is send • Get the changes only what you are interested in • No synchronous events for SPO  event-ing events
  • 40. Office Servers & Services MVP Azure / Office 365 / SharePoint @eliostruyf www.eliostruyf.com info@estruyf.be Elio Struyf Lead trainer and architect
  • 41. #SPSLondon - @eliostruyf Resources Certificate creation process with makecert - http://elst.es/2rhveZc Keycred GitHub - http://elst.es/2pW77vm All about the Change token - http://elst.es/2runG1M ChangeType enumeration - http://elst.es/2ruAfKn ChangeQuery properties - http://elst.es/2rib2q7 C# Sample application - http://elst.es/2qUYg0M Node.js / TypeScript sample application - http://elst.es/2qVpTqT or http://elst.es/2cycM82 SharePoint List WebHooks docs - http://elst.es/2qwl1as - http://elst.es/2quVjD0

Hinweis der Redaktion

  1. Template may not be modified Twitter hashtag: #SPSLondon for all sessions
  2. https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-token-and-claims  appidacr