Update webhook definition by ID - Fabric

Update webhook definition by ID

cURL

curl --request PATCH \
  --url https://prod01.oms.fabric.inc/api/v2/webhook/{webhookId} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-site-context: <x-site-context>' \
  --data '
{
  "target": "http://www.test.com",
  "protocol": "HTTP",
  "source": "OMS",
  "events": "[ORDER_CREATED]",
  "tenantId": "<string>",
  "targetApiKey": "adfasdWdsaQFSsdf",
  "apiVersion": "<string>",
  "format": "application/json",
  "callbackUrl": "<string>",
  "createdDate": "2023-11-07T05:31:56Z",
  "updatedDate": "2023-11-07T05:31:56Z"
}
'

Python

import requests

url = "https://prod01.oms.fabric.inc/api/v2/webhook/{webhookId}"

payload = {
    "target": "http://www.test.com",
    "protocol": "HTTP",
    "source": "OMS",
    "events": "[ORDER_CREATED]",
    "tenantId": "<string>",
    "targetApiKey": "adfasdWdsaQFSsdf",
    "apiVersion": "<string>",
    "format": "application/json",
    "callbackUrl": "<string>",
    "createdDate": "2023-11-07T05:31:56Z",
    "updatedDate": "2023-11-07T05:31:56Z"
}
headers = {
    "x-site-context": "<x-site-context>",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)

JavaScript (Fetch)

const options = {
  method: 'PATCH',
  headers: {
    'x-site-context': '<x-site-context>',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    target: 'http://www.test.com',
    protocol: 'HTTP',
    source: 'OMS',
    events: '[ORDER_CREATED]',
    tenantId: '<string>',
    targetApiKey: 'adfasdWdsaQFSsdf',
    apiVersion: '<string>',
    format: 'application/json',
    callbackUrl: '<string>',
    createdDate: '2023-11-07T05:31:56Z',
    updatedDate: '2023-11-07T05:31:56Z'
  })
};

fetch('https://prod01.oms.fabric.inc/api/v2/webhook/{webhookId}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://prod01.oms.fabric.inc/api/v2/webhook/{webhookId}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => json_encode([
    'target' => 'http://www.test.com',
    'protocol' => 'HTTP',
    'source' => 'OMS',
    'events' => '[ORDER_CREATED]',
    'tenantId' => '<string>',
    'targetApiKey' => 'adfasdWdsaQFSsdf',
    'apiVersion' => '<string>',
    'format' => 'application/json',
    'callbackUrl' => '<string>',
    'createdDate' => '2023-11-07T05:31:56Z',
    'updatedDate' => '2023-11-07T05:31:56Z'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json",
    "x-site-context: <x-site-context>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Responses

{
  "target": "http://www.test.com",
  "protocol": "HTTP",
  "source": "OMS",
  "events": "[ORDER_CREATED]",
  "webhookId": "<string>",
  "tenantId": "<string>",
  "targetApiKey": "adfasdWdsaQFSsdf",
  "apiVersion": "<string>",
  "format": "application/json",
  "callbackUrl": "<string>",
  "createdDate": "2023-11-07T05:31:56Z",
  "updatedDate": "2023-11-07T05:31:56Z"
}
{
  "message": "No webhook definition present for the given webhook Id"
}
{
  "message": "Webhook Definition with target, tenantId, protocol, source, apiVersion already exists!"
}
{
  "message": "Internal Server Error"
}

Authorizations

Headers

Path Parameters