Chilkat Online Tools

PowerBuilder / Sunshine Conversations API / List Webhooks

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Target
string ls_Id
string ls_Version
string ls_Secret
integer li_IncludeFullUser
integer li_IncludeFullSource
integer j
integer li_Count_j
string ls_StrVal
integer i
integer li_Count_i

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Http.BasicAuth = 1
loo_Http.Login = "username"
loo_Http.Password = "password"

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://domain.com/v2/apps/{{appId}}/integrations/:integrationId/webhooks",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

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

// {
//   "webhooks": [
//     {
//       "target": "http://example.com/callback",
//       "triggers": [
//         "conversation:read",
//         "conversation:message"
//       ],
//       "id": "5e554d2cac66fb73a3c01871",
//       "version": "v2",
//       "secret": "8564b3e6a8b20a4bdb68b05ce9bc5936",
//       "includeFullUser": false,
//       "includeFullSource": false
//     },
//     {
//       "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

i = 0
li_Count_i = loo_JResp.SizeOfArray("webhooks")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Target = loo_JResp.StringOf("webhooks[i].target")
    ls_Id = loo_JResp.StringOf("webhooks[i].id")
    ls_Version = loo_JResp.StringOf("webhooks[i].version")
    ls_Secret = loo_JResp.StringOf("webhooks[i].secret")
    li_IncludeFullUser = loo_JResp.BoolOf("webhooks[i].includeFullUser")
    li_IncludeFullSource = loo_JResp.BoolOf("webhooks[i].includeFullSource")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("webhooks[i].triggers")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("webhooks[i].triggers[j]")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

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

Postman Collection Item JSON

{
  "name": "List Webhooks",
  "_postman_id": "e26b4273-eac6-45b0-b422-94a66032e924",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{url}}/v2/apps/{{appId}}/integrations/:integrationId/webhooks",
      "host": [
        "{{url}}"
      ],
      "path": [
        "v2",
        "apps",
        "{{appId}}",
        "integrations",
        ":integrationId",
        "webhooks"
      ],
      "variable": [
        {
          "key": "integrationId"
        }
      ]
    },
    "description": "Lists all webhooks for a given Sunshine Conversations Connect integration or custom integration."
  },
  "response": [
    {
      "id": "07913ccc-e1de-4d52-8a75-1996f5ee1106",
      "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",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "integrations",
            ":integrationId",
            "webhooks"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "integrationId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "id": "9b583b6f-3cf6-4262-bcf0-35f341f3be42",
      "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",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "integrations",
            ":integrationId",
            "webhooks"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "integrationId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"webhooks\": [\n  {\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  {\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 ]\n}"
    },
    {
      "id": "b879b53a-38da-4d6c-b0ad-7a230406ee86",
      "name": "Forbidden",
      "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",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v2",
            "apps",
            ":appId",
            "integrations",
            ":integrationId",
            "webhooks"
          ],
          "variable": [
            {
              "key": "appId"
            },
            {
              "key": "integrationId"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}