Back to Collection Items
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim http As New ChilkatHttp
Dim success As Long
' Use this online tool to generate code from sample JSON: Generate Code to Create JSON
' The following JSON is sent in the request body.
' {
' "name": "WEBHOOK_NAME",
' "url": "https://example.com/webhook",
' "custom_headers": "id veniam consectetur ullamco",
' "encode_as": "json",
' "payload": "do offi"
' }
Dim json As New ChilkatJsonObject
success = json.UpdateString("name","WEBHOOK_NAME")
success = json.UpdateString("url","https://example.com/webhook")
success = json.UpdateString("custom_headers","id veniam consectetur ullamco")
success = json.UpdateString("encode_as","json")
success = json.UpdateString("payload","do offi")
http.SetRequestHeader "Content-Type","application/json"
http.SetRequestHeader "Accept","application/json"
Dim resp As ChilkatHttpResponse
Set resp = http.PostJson3("https://api.app.ddog-gov.com/api/v1/integration/webhooks/configuration/webhooks","application/json",json)
If (http.LastMethodSuccess = 0) Then
Debug.Print http.LastErrorText
Exit Sub
End If
Dim sbResponseBody As New ChilkatStringBuilder
success = resp.GetBodySb(sbResponseBody)
Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0
Debug.Print "Response Body:"
Debug.Print jResp.Emit()
Dim respStatusCode As Long
respStatusCode = resp.StatusCode
Debug.Print "Response Status Code = " & respStatusCode
If (respStatusCode >= 400) Then
Debug.Print "Response Header:"
Debug.Print resp.Header
Debug.Print "Failed."
Exit Sub
End If
' Sample JSON response:
' (Sample code for parsing the JSON response is shown below)
' {
' "name": "WEBHOOK_NAME",
' "url": "https://example.com/webhook",
' "custom_headers": "id veniam consectetur ullamco",
' "encode_as": "json",
' "payload": "do offi"
' }
' Sample code for parsing the JSON response...
' Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Dim name As String
name = jResp.StringOf("name")
Dim url As String
url = jResp.StringOf("url")
Dim custom_headers As String
custom_headers = jResp.StringOf("custom_headers")
Dim encode_as As String
encode_as = jResp.StringOf("encode_as")
Dim payload As String
payload = jResp.StringOf("payload")
Curl Command
curl -X POST
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"name": "WEBHOOK_NAME",
"url": "https://example.com/webhook",
"custom_headers": "id veniam consectetur ullamco",
"encode_as": "json",
"payload": "do offi"
}'
https://api.app.ddog-gov.com/api/v1/integration/webhooks/configuration/webhooks
Postman Collection Item JSON
{
"name": "Create a webhooks integration",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"WEBHOOK_NAME\",\n \"url\": \"https://example.com/webhook\",\n \"custom_headers\": \"id veniam consectetur ullamco\",\n \"encode_as\": \"json\",\n \"payload\": \"do offi\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/webhooks/configuration/webhooks",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"webhooks",
"configuration",
"webhooks"
]
},
"description": "Creates an endpoint with the name `<WEBHOOK_NAME>`."
},
"response": [
{
"name": "OK",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"WEBHOOK_NAME\",\n \"url\": \"https://example.com/webhook\",\n \"custom_headers\": \"id veniam consectetur ullamco\",\n \"encode_as\": \"json\",\n \"payload\": \"do offi\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/webhooks/configuration/webhooks",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"webhooks",
"configuration",
"webhooks"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"name\": \"WEBHOOK_NAME\",\n \"url\": \"https://example.com/webhook\",\n \"custom_headers\": \"id veniam consectetur ullamco\",\n \"encode_as\": \"json\",\n \"payload\": \"do offi\"\n}"
},
{
"name": "Bad Request",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"WEBHOOK_NAME\",\n \"url\": \"https://example.com/webhook\",\n \"custom_headers\": \"id veniam consectetur ullamco\",\n \"encode_as\": \"json\",\n \"payload\": \"do offi\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/webhooks/configuration/webhooks",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"webhooks",
"configuration",
"webhooks"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Authentication error",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"WEBHOOK_NAME\",\n \"url\": \"https://example.com/webhook\",\n \"custom_headers\": \"id veniam consectetur ullamco\",\n \"encode_as\": \"json\",\n \"payload\": \"do offi\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/webhooks/configuration/webhooks",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"webhooks",
"configuration",
"webhooks"
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
},
{
"name": "Too many requests",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "DD-API-KEY",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"WEBHOOK_NAME\",\n \"url\": \"https://example.com/webhook\",\n \"custom_headers\": \"id veniam consectetur ullamco\",\n \"encode_as\": \"json\",\n \"payload\": \"do offi\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/v1/integration/webhooks/configuration/webhooks",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"integration",
"webhooks",
"configuration",
"webhooks"
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"Bad Request\",\n \"Bad Request\"\n ]\n}"
}
]
}