Chilkat Online Tools

Powershell / Sunshine Conversations API / Get Webhook

Back to Collection Items

Add-Type -Path "C:\chilkat\ChilkatDotNet47-9.5.0-x64\ChilkatDotNet47.dll"

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

$http = New-Object Chilkat.Http

$http.BasicAuth = $true
$http.Login = "username"
$http.Password = "password"

$sbResponseBody = New-Object Chilkat.StringBuilder
$success = $http.QuickGetSb("https://domain.com/v2/apps/{{appId}}/integrations/:integrationId/webhooks/:webhookId",$sbResponseBody)
if ($success -eq $false) {
    $($http.LastErrorText)
    exit
}

$jResp = New-Object Chilkat.JsonObject
$jResp.LoadSb($sbResponseBody)
$jResp.EmitCompact = $false

$("Response Body:")
$($jResp.Emit())

$respStatusCode = $http.LastStatus
$("Response Status Code = " + $respStatusCode)
if ($respStatusCode -ge 400) {
    $("Response Header:")
    $($http.LastHeader)
    $("Failed.")
    exit
}

# Sample JSON response:
# (Sample code for parsing the JSON response is shown below)

# {
#   "webhook": {
#     "target": "http://example.com/callback",
#     "triggers": [
#       "conversation:read",
#       "conversation:message"
#     ],
#     "id": "5e554d2cac66fb73a3c01871",
#     "version": "v2",
#     "secret": "8564b3e6a8b20a4bdb68b05ce9bc5936",
#     "includeFullUser": false,
#     "includeFullSource": false
#   }
# }

# Sample code for parsing the JSON response...
# Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

$Target = $jResp.StringOf("webhook.target")
$Id = $jResp.StringOf("webhook.id")
$Version = $jResp.StringOf("webhook.version")
$Secret = $jResp.StringOf("webhook.secret")
$IncludeFullUser = $jResp.BoolOf("webhook.includeFullUser")
$IncludeFullSource = $jResp.BoolOf("webhook.includeFullSource")
$i = 0
$count_i = $jResp.SizeOfArray("webhook.triggers")
while ($i -lt $count_i) {
    $jResp.I = $i
    $strVal = $jResp.StringOf("webhook.triggers[i]")
    $i = $i + 1
}

Curl Command

curl -X GET
	-u 'username:password'
https://domain.com/v2/apps/{{appId}}/integrations/:integrationId/webhooks/:webhookId

Postman Collection Item JSON

{
  "name": "Get Webhook",
  "_postman_id": "53ff00f3-25eb-4c04-9236-d734ab114e9c",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{url}}/v2/apps/{{appId}}/integrations/:integrationId/webhooks/:webhookId",
      "host": [
        "{{url}}"
      ],
      "path": [
        "v2",
        "apps",
        "{{appId}}",
        "integrations",
        ":integrationId",
        "webhooks",
        ":webhookId"
      ],
      "variable": [
        {
          "key": "integrationId"
        },
        {
          "key": "webhookId"
        }
      ]
    },
    "description": "Gets the specified webhook associated with a Sunshine Conversations Connect integration or a custom integration."
  },
  "response": [
    {
      "id": "38580f86-f580-45a4-b44e-e8b5fe7eb249",
      "name": "Ok",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/integrations/:integrationId/webhooks/:webhookId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "integrations",
            ":integrationId",
            "webhooks",
            ":webhookId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "integrationId"
            },
            {
              "key": "webhookId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"webhook\": {\n  \"target\": \"http://example.com/callback\",\n  \"triggers\": [\n   \"conversation:read\",\n   \"conversation:message\"\n  ],\n  \"id\": \"5e554d2cac66fb73a3c01871\",\n  \"version\": \"v2\",\n  \"secret\": \"8564b3e6a8b20a4bdb68b05ce9bc5936\",\n  \"includeFullUser\": false,\n  \"includeFullSource\": false\n }\n}"
    },
    {
      "id": "4818c85e-2c1e-4517-9caf-d42cd9952dc1",
      "name": "Not Found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: bearer",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "Bearer <token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v2/apps/:appId/integrations/:integrationId/webhooks/:webhookId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "integrations",
            ":integrationId",
            "webhooks",
            ":webhookId"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "integrationId"
            },
            {
              "key": "webhookId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}