Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vQueryParams
Handle hoQueryParams
Variant vResp
Handle hoResp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sId
String sV_type
String sStatus
String sDisplayName
String sServerId
Boolean iCanUserCreateMoreConversations
Boolean iHasMore
String sAfterCursor
String sBeforeCursor
String sPrev
String sAfter
Integer i
Integer iCount_i
String sTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Set ComBasicAuth Of hoHttp To True
Set ComLogin Of hoHttp To "username"
Set ComPassword Of hoHttp To "password"
Get Create (RefClass(cComChilkatJsonObject)) To hoQueryParams
If (Not(IsComObjectCreated(hoQueryParams))) Begin
Send CreateComObject of hoQueryParams
End
Get ComUpdateString Of hoQueryParams "page[after]" "5e1606762556d93e9c176f69" To iSuccess
Get ComUpdateString Of hoQueryParams "page[before]" "5e1606762556d93e9c176f69" To iSuccess
Get ComUpdateInt Of hoQueryParams "page[size]" 10 To iSuccess
Get ComUpdateString Of hoQueryParams "filter[types]" "android,ios" To iSuccess
Get pvComObject of hoQueryParams to vQueryParams
Get ComQuickRequestParams Of hoHttp "GET" "https://domain.com/v2/apps/{{appId}}/integrations" vQueryParams To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Send Destroy of hoResp
Procedure_Return
End
Send Destroy of hoResp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "integrations": [
// {
// "id": "5e4af71a81966cfff3ef6550",
// "type": "android",
// "status": "active",
// "displayName": "Android",
// "serverId": "<sender-id>",
// "canUserCreateMoreConversations": true
// }
// ],
// "meta": {
// "hasMore": true,
// "afterCursor": "5e4af71a81966cfff3ef6550",
// "beforeCursor": "5e4af71a81966cfff3ef6550"
// },
// "links": {
// "prev": "https://api.smooch.io/v2/apps/5e4af71a81966cfff3ef6551/integrations?page[before]=5e4af71a81966cfff3ef6550",
// "after": "https://api.smooch.io/v2/apps/5e4af71a81966cfff3ef6551/integrations?page[after]=5e4af71a81966cfff3ef6550"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Get ComBoolOf Of hoJResp "meta.hasMore" To iHasMore
Get ComStringOf Of hoJResp "meta.afterCursor" To sAfterCursor
Get ComStringOf Of hoJResp "meta.beforeCursor" To sBeforeCursor
Get ComStringOf Of hoJResp "links.prev" To sPrev
Get ComStringOf Of hoJResp "links.after" To sAfter
Move 0 To i
Get ComSizeOfArray Of hoJResp "integrations" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "integrations[i].id" To sId
Get ComStringOf Of hoJResp "integrations[i].type" To sV_type
Get ComStringOf Of hoJResp "integrations[i].status" To sStatus
Get ComStringOf Of hoJResp "integrations[i].displayName" To sDisplayName
Get ComStringOf Of hoJResp "integrations[i].serverId" To sServerId
Get ComBoolOf Of hoJResp "integrations[i].canUserCreateMoreConversations" To iCanUserCreateMoreConversations
Move (i + 1) To i
Loop
End_Procedure
Curl Command
curl -G -d "page[after]=5e1606762556d93e9c176f69"
-d "page[before]=5e1606762556d93e9c176f69"
-d "page[size]=10"
-d "filter[types]=android,ios"
-u 'username:password'
https://domain.com/v2/apps/{{appId}}/integrations
Postman Collection Item JSON
{
"name": "List Integrations",
"_postman_id": "910e1daa-764e-4d53-a9a8-dc911aeffeb5",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{url}}/v2/apps/{{appId}}/integrations?page[after]=5e1606762556d93e9c176f69&page[before]=5e1606762556d93e9c176f69&page[size]=10&filter[types]=android,ios",
"host": [
"{{url}}"
],
"path": [
"v2",
"apps",
"{{appId}}",
"integrations"
],
"query": [
{
"key": "page[after]",
"value": "5e1606762556d93e9c176f69",
"description": "Contains parameters for applying cursor pagination."
},
{
"key": "page[before]",
"value": "5e1606762556d93e9c176f69",
"description": "Contains parameters for applying cursor pagination."
},
{
"key": "page[size]",
"value": "10",
"description": "Contains parameters for applying cursor pagination."
},
{
"key": "filter[types]",
"value": "android,ios",
"description": "Contains parameters for filtering the results."
}
]
},
"description": "List available integrations. This API is paginated through [cursor pagination](#section/Introduction/API-pagination-and-records-limits).\n```shell\n/v2/apps/:appId/integrations?page[after]=5e1606762556d93e9c176f69&page[size]=10&filter[types]=custom,web\n```\n"
},
"response": [
{
"id": "5cc09374-9a2f-4d9e-95fd-f5bb91aa63d6",
"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?page[after]=5e1606762556d93e9c176f69&page[before]=5e1606762556d93e9c176f69&page[size]=10&filter[types]=android,ios",
"host": [
"{{baseUrl}}"
],
"path": [
"v2",
"apps",
":appId",
"integrations"
],
"query": [
{
"key": "page[after]",
"value": "5e1606762556d93e9c176f69"
},
{
"key": "page[before]",
"value": "5e1606762556d93e9c176f69"
},
{
"key": "page[size]",
"value": "10"
},
{
"key": "filter[types]",
"value": "android,ios"
}
],
"variable": [
{
"key": "appId"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"integrations\": [\n {\n \"id\": \"5e4af71a81966cfff3ef6550\",\n \"type\": \"android\",\n \"status\": \"active\",\n \"displayName\": \"Android\",\n \"serverId\": \"<sender-id>\",\n \"canUserCreateMoreConversations\": true\n }\n ],\n \"meta\": {\n \"hasMore\": true,\n \"afterCursor\": \"5e4af71a81966cfff3ef6550\",\n \"beforeCursor\": \"5e4af71a81966cfff3ef6550\"\n },\n \"links\": {\n \"prev\": \"https://api.smooch.io/v2/apps/5e4af71a81966cfff3ef6551/integrations?page[before]=5e4af71a81966cfff3ef6550\",\n \"after\": \"https://api.smooch.io/v2/apps/5e4af71a81966cfff3ef6551/integrations?page[after]=5e4af71a81966cfff3ef6550\"\n }\n}"
}
]
}