Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loQueryParams
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcCreated_time
LOCAL lcModified_time
LOCAL lcName
LOCAL lcName
LOCAL lcId
LOCAL lcId
LOCAL lcCreated_byName
LOCAL lcCreated_byId
LOCAL lnCount
LOCAL lnAllowed_count
LOCAL i
LOCAL lnCount_i
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loQueryParams = CreateObject('Chilkat.JsonObject')
loQueryParams.UpdateString("module","Leads")
* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"
loResp = loHttp.QuickRequestParams("GET","https://domain.com/crm/v2/settings/tags",loQueryParams)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loQueryParams
CANCEL
ENDIF
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0
? "Response Body:"
? loJResp.Emit()
lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loResp.Header
? "Failed."
RELEASE loResp
RELEASE loHttp
RELEASE loQueryParams
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
RELEASE loResp
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "tags": [
* {
* "created_time": "2021-05-07T12:40:30+00:00",
* "modified_time": "2021-05-07T12:40:30+00:00",
* "name": "test",
* "modified_by": {
* "name": "Patricia Boyle",
* "id": "738964000000291009"
* },
* "id": "738964000002130345",
* "created_by": {
* "name": "Patricia Boyle",
* "id": "738964000000291009"
* }
* },
* {
* "created_time": "2021-05-12T06:33:15+00:00",
* "modified_time": "2021-05-12T06:33:15+00:00",
* "name": "Nurturing Lead2",
* "modified_by": {
* "name": "Patricia Boyle",
* "id": "738964000000291009"
* },
* "id": "738964000002152055",
* "created_by": {
* "name": "Patricia Boyle",
* "id": "738964000000291009"
* }
* },
* {
* "created_time": "2021-05-12T06:33:15+00:00",
* "modified_time": "2021-05-12T06:33:15+00:00",
* "name": "Qualifies Lead2",
* "modified_by": {
* "name": "Patricia Boyle",
* "id": "738964000000291009"
* },
* "id": "738964000002152056",
* "created_by": {
* "name": "Patricia Boyle",
* "id": "738964000000291009"
* }
* },
* {
* "created_time": "2021-05-12T06:42:36+00:00",
* "modified_time": "2021-05-12T06:42:36+00:00",
* "name": "Tag1",
* "modified_by": {
* "name": "Patricia Boyle",
* "id": "738964000000291009"
* },
* "id": "738964000002152073",
* "created_by": {
* "name": "Patricia Boyle",
* "id": "738964000000291009"
* }
* }
* ],
* "info": {
* "count": 4,
* "allowed_count": 100
* }
* }
* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
lnCount = loJResp.IntOf("info.count")
lnAllowed_count = loJResp.IntOf("info.allowed_count")
i = 0
lnCount_i = loJResp.SizeOfArray("tags")
DO WHILE i < lnCount_i
loJResp.I = i
lcCreated_time = loJResp.StringOf("tags[i].created_time")
lcModified_time = loJResp.StringOf("tags[i].modified_time")
lcName = loJResp.StringOf("tags[i].name")
lcName = loJResp.StringOf("tags[i].modified_by.name")
lcId = loJResp.StringOf("tags[i].modified_by.id")
lcId = loJResp.StringOf("tags[i].id")
lcCreated_byName = loJResp.StringOf("tags[i].created_by.name")
lcCreated_byId = loJResp.StringOf("tags[i].created_by.id")
i = i + 1
ENDDO
RELEASE loHttp
RELEASE loQueryParams
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -G -d "module=Leads"
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2/settings/tags
Postman Collection Item JSON
{
"name": "Leads",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags?module=Leads",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags"
],
"query": [
{
"key": "module",
"value": "Leads"
}
]
},
"description": "To display all the tags in the Leads module"
},
"response": [
{
"name": "P1: module",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags?module=Leads",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags"
],
"query": [
{
"key": "module",
"value": "Leads"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Thu, 13 May 2021 09:03:42 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-store, no-cache, must-revalidate, private"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-13T09:52:40+00:00"
},
{
"key": "clientVersion",
"value": "4031107"
},
{
"key": "clientsubVersion",
"value": "113b962796fc62946d9303284a64efab"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "vary",
"value": "accept-encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
}
],
"cookie": [
],
"body": "{\n \"tags\": [\n {\n \"created_time\": \"2021-05-07T12:40:30+00:00\",\n \"modified_time\": \"2021-05-07T12:40:30+00:00\",\n \"name\": \"test\",\n \"modified_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n },\n \"id\": \"738964000002130345\",\n \"created_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n }\n },\n {\n \"created_time\": \"2021-05-12T06:33:15+00:00\",\n \"modified_time\": \"2021-05-12T06:33:15+00:00\",\n \"name\": \"Nurturing Lead2\",\n \"modified_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n },\n \"id\": \"738964000002152055\",\n \"created_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n }\n },\n {\n \"created_time\": \"2021-05-12T06:33:15+00:00\",\n \"modified_time\": \"2021-05-12T06:33:15+00:00\",\n \"name\": \"Qualifies Lead2\",\n \"modified_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n },\n \"id\": \"738964000002152056\",\n \"created_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n }\n },\n {\n \"created_time\": \"2021-05-12T06:42:36+00:00\",\n \"modified_time\": \"2021-05-12T06:42:36+00:00\",\n \"name\": \"Tag1\",\n \"modified_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n },\n \"id\": \"738964000002152073\",\n \"created_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n }\n }\n ],\n \"info\": {\n \"count\": 4,\n \"allowed_count\": 100\n }\n}"
},
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags?module=Leads",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags"
],
"query": [
{
"key": "module",
"value": "Leads"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:27:09 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "849"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-store, no-cache, must-revalidate, private"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-12T07:15:06+00:00"
},
{
"key": "clientVersion",
"value": "4027076"
},
{
"key": "clientsubVersion",
"value": "748ecbe82ec7e144b66ee25f264bbd88"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "Content-Language",
"value": "en-US"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
}
],
"cookie": [
],
"body": "{\n \"tags\": [\n {\n \"created_time\": \"2021-05-07T12:38:01+00:00\",\n \"modified_time\": \"2021-05-07T12:38:01+00:00\",\n \"name\": \"Nurturing Lead\",\n \"modified_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n },\n \"id\": \"738964000002130339\",\n \"created_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n }\n },\n {\n \"created_time\": \"2021-05-07T12:38:01+00:00\",\n \"modified_time\": \"2021-05-07T12:38:01+00:00\",\n \"name\": \"Qualifies Lead\",\n \"modified_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n },\n \"id\": \"738964000002130340\",\n \"created_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n }\n },\n {\n \"created_time\": \"2021-05-07T12:40:30+00:00\",\n \"modified_time\": \"2021-05-07T12:40:30+00:00\",\n \"name\": \"test\",\n \"modified_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n },\n \"id\": \"738964000002130345\",\n \"created_by\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"738964000000291009\"\n }\n }\n ],\n \"info\": {\n \"count\": 3,\n \"allowed_count\": 100\n }\n}"
},
{
"name": "INVALID_URL_PATTERN",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tag?module=Leads",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tag"
],
"query": [
{
"key": "module",
"value": "Leads"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:27:46 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "131"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-store, no-cache, must-revalidate, private"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-12T07:15:06+00:00"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "Content-Language",
"value": "en-US"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_URL_PATTERN\",\n \"details\": {},\n \"message\": \"Please check if the URL trying to access is a correct one\",\n \"status\": \"error\"\n}"
},
{
"name": "INVALID_MODULE",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags?module=Lead",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags"
],
"query": [
{
"key": "module",
"value": "Lead"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:28:01 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "110"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-store, no-cache, must-revalidate, private"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-12T07:15:06+00:00"
},
{
"key": "clientVersion",
"value": "4027076"
},
{
"key": "clientsubVersion",
"value": "748ecbe82ec7e144b66ee25f264bbd88"
},
{
"key": "Content-Disposition",
"value": "attachment; filename=response.json"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "Content-Language",
"value": "en-US"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_MODULE\",\n \"details\": {},\n \"message\": \"the module name given seems to be invalid\",\n \"status\": \"error\"\n}"
},
{
"name": "INVALID_REQUEST_METHOD",
"originalRequest": {
"method": "COPY",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags?module=Leads",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags"
],
"query": [
{
"key": "module",
"value": "Leads"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:28:16 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "124"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Frame-Options",
"value": "deny"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_REQUEST_METHOD\",\n \"details\": {},\n \"message\": \"The http request method type is not a valid one\",\n \"status\": \"error\"\n}"
},
{
"name": "AUTHENTICATION_FAILURE",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags?module=Leads",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags"
],
"query": [
{
"key": "module",
"value": "Leads"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:28:34 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "98"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-Download-Options",
"value": "noopen"
}
],
"cookie": [
],
"body": "{\n \"code\": \"AUTHENTICATION_FAILURE\",\n \"details\": {},\n \"message\": \"Authentication failed\",\n \"status\": \"error\"\n}"
},
{
"name": "REQUIRED_PARAM_MISSING",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 12 May 2021 06:28:48 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "133"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-Download-Options",
"value": "noopen"
}
],
"cookie": [
],
"body": "{\n \"code\": \"REQUIRED_PARAM_MISSING\",\n \"details\": {\n \"param\": \"module\"\n },\n \"message\": \"One of the expected parameter is missing\",\n \"status\": \"error\"\n}"
},
{
"name": "OAUTH_SCOPE_MISMATCH",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2/settings/tags?module=Leads",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"settings",
"tags"
],
"query": [
{
"key": "module",
"value": "Leads"
}
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Thu, 13 May 2021 08:31:38 GMT"
},
{
"key": "Content-Type",
"value": "application/json;charset=utf-8"
},
{
"key": "Content-Length",
"value": "113"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Referrer-Policy",
"value": "strict-origin"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-Download-Options",
"value": "noopen"
}
],
"cookie": [
],
"body": "{\n \"code\": \"OAUTH_SCOPE_MISMATCH\",\n \"details\": {},\n \"message\": \"invalid oauth scope to access this URL\",\n \"status\": \"error\"\n}"
}
]
}