1. Webhook Setup
2 minute read
Build Outcome
By the end of this section we will have:
- Set up a Product Created Webhook in Marketplacer
- Tested that the Webhook fires
Note
This step is essentially just setting up a webhook in Marketplacer, for a deeper dive discussion on webhooks, please refer to our dedicated docs on webhooks.Steps
Companion Video
The companion video for this section can be found here.Create the webhook
Login to the Marketplacer Operator Portal as an Administrator, and:
1: Expand Configuration and select Webhooks
2: Select New Webhook
3: Populate the webhook creation fields
- Enabled: True - Activates / Deactivates the webhook
- Type: Advert - The object type we are interested in
- Event Name (filter): Create - The event type we are interested in
- URL: This will be our Azure HTTP trigger function eventually, for now you can populate with a test endpoint supplied by: webhook.site
Note: webhook.site is a 3rd party app which will receive webhook payloads from Marketplacer, please use at your own discretion.
- Headers:
{"AuthKey":"<some key value>"}
- We will be validating this header in our Azure function to determine whether we can trust this webhook event. Please generate your own unique key value. Headers are defined as JSON objects. - GraphQL: This is a GraphQL query that shapes our webhook payload. An example query is shown below that you can use:
query ($id: ID!) {
node(id: $id) {
... on Advert {
__typename
id
legacyId
title
description
variants {
nodes {
id
sku
countOnHand
}
}
}
}
}
We provide more examples of the queries you can use to shape your webhook payloads in our API collections (see the Webhook Query Template folder.)
4: When you are happy, clicking Save will return you to the newly created webhook.
Test the webhook
5: To test this webhook we need to create an Advert in Marketplacer, you can do this in one of the following ways:
- Manually create in the Seller Portal
- Use the Seller API
advertUpsert
mutation- Instructions on how to do this can be found here
- CSV Upload
Creating an Advert should result in an event being generated in webhook.site as follows:
Next Up: Azure HTTP Trigger Function