I am not sure where/how to set up a webhook in servicem8. I want to trigger an update when a Job status changes from Quote to Work Order. I have read the documentation, but am not clear on the process.
1 Answers
Webhooks in ServiceM8 are only supported when using OAuth authentication using an access token, so you will need to register for a free developer account to get your OAuth Client Id and Secret. If you have not yet done so, follow the steps listed here: http://developer.servicem8.com/docs/the-basics/public-applications/
Once you have OAuth authentication working, Subscribe to the 'Job' webhook to receive notifications when job data has changed. Do this by POSTing to https://api.servicem8.com/webhook_subscriptions
As mentioned on http://developer.servicem8.com/docs/platform-services/webhooks/ , the subscribe request should include:
- object='job'
- fields='status'
- callback_url - Set this to the URL you wish to receive notifications
Once you subscribe to the webhook, you will immediately receive a request at your callback url to challenge you own this url. The request will contain URL parameters mode=subscribe, and a challenge value. To successfully confirm the challenge request you need to return a 200 result, with the body of the response set to the challenge code.
If you successfully confirm the challenge code request, you will start receiving notifications at your callback_url for any changes to job data within your ServiceM8 account. The notification you receive will contain JSON data similar to
{
"object": "job",
"entry": {
"changed_fields": ["status"],
"time": "2015-01-01 00:00:00",
"uuid": "de305d54-75b4-431b-adb2-eb6b9e546013"
},
"resource_url": "https://api.servicem8.com/api_1.0/job/de305d54-75b4-431b-adb2-eb6b9e546013.json"
}`

- 148
- 1
- 8
-
Thanks Brinkin, I finally got a chance to code this up! Getting stuck though on the callback url challenge. When I subscribe to the web hook I get the following response: {"success":false,"message":"Invalid callback challenge key returned"} and I do not get anything in the headers. What am I missing...? – anniec Sep 29 '16 at 20:31
-
@anniec Did you ever figure out the verification? I'm getting the same response. – joshlsullivan Jan 30 '18 at 04:47