Back to Collection Items
IncludeFile "CkJsonArray.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
CkHttp::ckSetRequestHeader(http,"API-Key","{{API_KEY}}")
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckQuickGetSb(http,"https://api.shipengine.com/v1/environment/webhooks",sbResponseBody)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
jarrResp.i = CkJsonArray::ckCreate()
If jarrResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonArray::ckLoadSb(jarrResp,sbResponseBody)
CkJsonArray::setCkEmitCompact(jarrResp, 0)
Debug "Response Body:"
Debug CkJsonArray::ckEmit(jarrResp)
respStatusCode.i = CkHttp::ckLastStatus(http)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttp::ckLastHeader(http)
Debug "Failed."
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonArray::ckDispose(jarrResp)
ProcedureReturn
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; [
; {
; "webhook_id": "102349",
; "url": "https://your-domain-here.com/some/path",
; "event": "track"
; }
; ]
; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
json.i
webhook_id.s
url.s
v_event.s
i.i = 0
count_i.i = CkJsonArray::ckSize(jarrResp)
While i < count_i
json = CkJsonArray::ckObjectAt(jarrResp,i)
webhook_id = CkJsonObject::ckStringOf(json,"webhook_id")
url = CkJsonObject::ckStringOf(json,"url")
v_event = CkJsonObject::ckStringOf(json,"event")
CkJsonObject::ckDispose(json)
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonArray::ckDispose(jarrResp)
ProcedureReturn
EndProcedure
Curl Command
curl -X GET
-H "API-Key: {{API_KEY}}"
https://api.shipengine.com/v1/environment/webhooks
Postman Collection Item JSON
{
"name": "List your webhooks",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.shipengine.com/v1/environment/webhooks",
"protocol": "https",
"host": [
"api",
"shipengine",
"com"
],
"path": [
"v1",
"environment",
"webhooks"
]
},
"description": "This request lists all of the webhooks that you've setup, either via the API or the ShipEngine web dashboard."
},
"response": [
{
"name": "List your webhooks",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.shipengine.com/v1/environment/webhooks",
"protocol": "https",
"host": [
"api",
"shipengine",
"com"
],
"path": [
"v1",
"environment",
"webhooks"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 18 Sep 2019 19:15:31 GMT"
},
{
"key": "Content-Type",
"value": "application/json; charset=utf-8"
},
{
"key": "Content-Length",
"value": "119"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Access-Control-Allow-Origin",
"value": "https://www.shipengine.com"
},
{
"key": "Vary",
"value": "Origin"
},
{
"key": "x-shipengine-requestid",
"value": "9a84eb30-c0bb-4942-bed9-fe9d051bd810"
}
],
"cookie": [
],
"body": "[\n {\n \"webhook_id\": \"102349\",\n \"url\": \"https://your-domain-here.com/some/path\",\n \"event\": \"track\"\n }\n]"
}
]
}