The following examples show how to make POST (create), GET (read), PATCH (update), and DELETE requests using the Webhook Service Meta API.
The webhook examples in this topic are based on an Integration Object called EmployeeIO. To create the Integration Object, send POST request https://localhost:9002/odata2webservices/IntegrationService/InboundChannelConfigurations with the following body:
Sample Code
{
"integrationObject": {
"code": "EmployeeIO",
"items": [
{
"root": false,
"code": "UserGroup",
"type": {
"code": "UserGroup"
},
"attributes": [
{
"attributeName": "uid",
"attributeDescriptor": {
"qualifier": "uid",
"enclosingType": {
"code": "UserGroup"
}
},
"unique": true
}
]
},
{
"root": true,
"code": "Employee",
"type": {
"code": "Employee"
},
"attributes": [
{
"attributeName": "name",
"attributeDescriptor": {
"qualifier": "name",
"enclosingType": {
"code": "Employee"
}
}
},
{
"attributeName": "uid",
"attributeDescriptor": {
"qualifier": "uid",
"enclosingType": {
"code": "Employee"
}
},
"unique": true
},
{
"attributeName": "password",
"attributeDescriptor": {
"qualifier": "password",
"enclosingType": {
"code": "Employee"
}
}
},
{
"attributeName": "groups",
"attributeDescriptor": {
"qualifier": "groups",
"enclosingType": {
"code": "Employee"
}
},
"returnIntegrationObjectItem": {
"code": "UserGroup"
}
}
]
}
]
},
"authenticationType": {
"code": "BASIC"
}
}
Here is the response body that is returned:
Sample Code
"d": {
"__metadata": {
"id": "https://localhost:9002/odata2webservices/IntegrationService/InboundChannelConfigurations('EmployeeIO')",
"uri": "https://localhost:9002/odata2webservices/IntegrationService/InboundChannelConfigurations('EmployeeIO')",
"type": "HybrisCommerceOData.InboundChannelConfiguration"
},
"integrationKey": "EmployeeIO",
"authenticationType": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/IntegrationService/InboundChannelConfigurations('EmployeeIO')/authenticationType"
}
},
"integrationObject": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/IntegrationService/InboundChannelConfigurations('EmployeeIO')/integrationObject"
}
}
}
}
POST a Webhook
Send POST request https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations with the following body:
Sample Code
{
"eventType": "de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationObject": {
"code": "EmployeeIO"
},
"destination": {
"id": "ExistingWebhookDestination",
"destinationTarget": {
"id": "webhookServices"
}
}
}
Here is the response body that is returned:
Sample Code
{
"d": {
"__metadata": {
"id": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"type": "HybrisCommerceOData.WebhookConfiguration"
},
"filterLocation": null,
"eventType": "de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationKey": "ExistingWebhookDestination|webhookServices|EmployeeIO|de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationObject": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/integrationObject"
}
},
"destination": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/destination"
}
}
}
}
POST a Webhook with Nested Destination Elements
Send POST request https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations with the following body:
Sample Code
"eventType": "de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationObject": {
"code": "EmployeeIO"
},
"destination": {
"id": "NewDestination",
"url": "https://postman-echo.com/post",
"destinationTarget": {
"id": "NewTarget",
"destinationChannel": {
"code": "WEBHOOKSERVICES"
},
"eventConfigurations": [
{
"eventClass": "de.hybris.platform.webhookservices.event.ItemSavedEvent",
"exportName": "does not matter but must be present"
}
]
},
"endpoint": {
"id": "NewEndpoint",
"version": "test",
"name": "Postman echo",
"specUrl": "https://postman-echo.com"
},
"credentialBasic": {
"id": "NewCredential",
"username": "postman",
"password": "test"
}
},
"filterLocation": "model://someScript"
}
Here is the response body that is returned:
Sample Code
{
"d": {
"__metadata": {
"id": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('NewDestination%7CNewTarget%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('NewDestination%7CNewTarget%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"type": "HybrisCommerceOData.WebhookConfiguration"
},
"filterLocation": "model://someScript",
"eventType": "de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationKey": "NewDestination|NewTarget|EmployeeIO|de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationObject": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('NewDestination%7CNewTarget%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/integrationObject"
}
},
"destination": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('NewDestination%7CNewTarget%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/destination"
}
}
}
}
GET a Webhook by Key
Send PATCH request https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations ('<integrationKey>') .
For example, https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')
Here is the response body that is returned:
Sample Code
{
"d": {
"__metadata": {
"id": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"type": "HybrisCommerceOData.WebhookConfiguration"
},
"filterLocation": null,
"eventType": "de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationKey": "ExistingWebhookDestination|webhookServices|EmployeeIO|de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationObject": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/integrationObject"
}
},
"destination": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/destination"
}
}
}
}
GET All Webhooks
Send GET request: https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations
Here is the response body that is returned:
Sample Code
{
"d": {
"results": [
{
"__metadata": {
"id": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('NewDestination%7CNewTarget%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('NewDestination%7CNewTarget%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"type": "HybrisCommerceOData.WebhookConfiguration"
},
"filterLocation": "model://someScript",
"eventType": "de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationKey": "NewDestination|NewTarget|EmployeeIO|de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationObject": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('NewDestination%7CNewTarget%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/integrationObject"
}
},
"destination": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('NewDestination%7CNewTarget%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/destination"
}
}
}
]
}
}
PATCH a Webhook
Send PATCH request: https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations ('<integrationKey>') .
For example, https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent') , with the following body:
Here is the response body that is returned:
Sample Code
{
"d": {
"__metadata": {
"id": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')",
"type": "HybrisCommerceOData.WebhookConfiguration"
},
"filterLocation": "model://someScript",
"eventType": "de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationKey": "ExistingWebhookDestination|webhookServices|EmployeeIO|de.hybris.platform.webhookservices.event.ItemSavedEvent",
"integrationObject": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/integrationObject"
}
},
"destination": {
"__deferred": {
"uri": "https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')/destination"
}
}
}
}
DELETE a Webhook
Send DELETE request: https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations ('<integrationKey>') .
For example, https://localhost:9002/odata2webservices/WebhookService/WebhookConfigurations('ExistingWebhookDestination%7CwebhookServices%7CEmployeeIO%7Cde.hybris.platform.webhookservices.event.ItemSavedEvent')
No response body is returned.