Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcName
LOCAL lcId
LOCAL lcV_Email
LOCAL lcModified_Time
LOCAL lcFile_Name
LOCAL lcCreated_Time
LOCAL lcSize
LOCAL lcParent_IdName
LOCAL lcParent_IdId
LOCAL lnSeditable
LOCAL lcSsharing_permission
LOCAL lcSfile_id
LOCAL lcStype
LOCAL lcSse_module
LOCAL lcModified_ByName
LOCAL lcModified_ById
LOCAL lcModified_ByEmail
LOCAL lnSattachment_type
LOCAL lcSstate
LOCAL lcId
LOCAL lcCreated_ByName
LOCAL lcCreated_ById
LOCAL lcCreated_ByEmail
LOCAL lcSlink_url
LOCAL lnPer_page
LOCAL lnCount
LOCAL lnPage
LOCAL lnMore_records
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')
* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://domain.com/crm/v2.1/Leads/{{record_id}}/Attachments",loSbResponseBody)
IF (lnSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loSbResponseBody
CANCEL
ENDIF
* 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 = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
? "Response Header:"
? loHttp.LastHeader
? "Failed."
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp
CANCEL
ENDIF
* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)
* {
* "data": [
* {
* "Owner": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "Modified_Time": "2021-05-03T17:59:02+05:30",
* "File_Name": "0f2b4454e6fea3b4c8fcc82e7d2601b0.jpg",
* "Created_Time": "2021-05-03T17:59:02+05:30",
* "Size": "563181",
* "Parent_Id": {
* "name": "Brian Dolan",
* "id": "4150868000004943003"
* },
* "$editable": true,
* "$sharing_permission": "full_access",
* "$file_id": "1nvs60c82c750d8564edeaf5093ecadff1c9a",
* "$type": "Attachment",
* "$se_module": "Leads",
* "Modified_By": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "$attachment_type": 0,
* "$state": "save",
* "id": "4150868000005282007",
* "Created_By": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "$link_url": null
* },
* {
* "Owner": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "Modified_Time": "2021-05-03T18:05:58+05:30",
* "File_Name": "4150868000001144115.zip",
* "Created_Time": "2021-05-03T18:05:58+05:30",
* "Size": "335",
* "Parent_Id": {
* "name": "Brian Dolan",
* "id": "4150868000004943003"
* },
* "$editable": true,
* "$sharing_permission": "full_access",
* "$file_id": "1nvs652667149a3684a938b5e751e55a280f5",
* "$type": "Attachment",
* "$se_module": "Leads",
* "Modified_By": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "$attachment_type": 0,
* "$state": "save",
* "id": "4150868000005277042",
* "Created_By": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "$link_url": null
* },
* {
* "Owner": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "Modified_Time": "2021-05-03T18:03:00+05:30",
* "File_Name": "0f2b4454e6fea3b4c8fcc82e7d2601b0.jpg",
* "Created_Time": "2021-05-03T18:03:00+05:30",
* "Size": "563181",
* "Parent_Id": {
* "name": "Brian Dolan",
* "id": "4150868000004943003"
* },
* "$editable": true,
* "$sharing_permission": "full_access",
* "$file_id": "1nvs632039a760ec04736b291c070a4a60b11",
* "$type": "Attachment",
* "$se_module": "Leads",
* "Modified_By": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "$attachment_type": 0,
* "$state": "save",
* "id": "4150868000005277036",
* "Created_By": {
* "name": "Patricia Boyle",
* "id": "4150868000000225013",
* "email": "patricia.ss@zylker.com"
* },
* "$link_url": null
* }
* ],
* "info": {
* "per_page": 200,
* "count": 3,
* "page": 1,
* "more_records": false
* }
* }
* Sample code for parsing the JSON response...
* Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
lnPer_page = loJResp.IntOf("info.per_page")
lnCount = loJResp.IntOf("info.count")
lnPage = loJResp.IntOf("info.page")
lnMore_records = loJResp.BoolOf("info.more_records")
i = 0
lnCount_i = loJResp.SizeOfArray("data")
DO WHILE i < lnCount_i
loJResp.I = i
lcName = loJResp.StringOf("data[i].Owner.name")
lcId = loJResp.StringOf("data[i].Owner.id")
lcV_Email = loJResp.StringOf("data[i].Owner.email")
lcModified_Time = loJResp.StringOf("data[i].Modified_Time")
lcFile_Name = loJResp.StringOf("data[i].File_Name")
lcCreated_Time = loJResp.StringOf("data[i].Created_Time")
lcSize = loJResp.StringOf("data[i].Size")
lcParent_IdName = loJResp.StringOf("data[i].Parent_Id.name")
lcParent_IdId = loJResp.StringOf("data[i].Parent_Id.id")
lnSeditable = loJResp.BoolOf("data[i].$editable")
lcSsharing_permission = loJResp.StringOf("data[i].$sharing_permission")
lcSfile_id = loJResp.StringOf("data[i].$file_id")
lcStype = loJResp.StringOf("data[i].$type")
lcSse_module = loJResp.StringOf("data[i].$se_module")
lcModified_ByName = loJResp.StringOf("data[i].Modified_By.name")
lcModified_ById = loJResp.StringOf("data[i].Modified_By.id")
lcModified_ByEmail = loJResp.StringOf("data[i].Modified_By.email")
lnSattachment_type = loJResp.IntOf("data[i].$attachment_type")
lcSstate = loJResp.StringOf("data[i].$state")
lcId = loJResp.StringOf("data[i].id")
lcCreated_ByName = loJResp.StringOf("data[i].Created_By.name")
lcCreated_ById = loJResp.StringOf("data[i].Created_By.id")
lcCreated_ByEmail = loJResp.StringOf("data[i].Created_By.email")
lcSlink_url = loJResp.StringOf("data[i].$link_url")
i = i + 1
ENDDO
RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2.1/Leads/{{record_id}}/Attachments
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.1/Leads/{{record_id}}/Attachments",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"{{record_id}}",
"Attachments"
]
},
"description": "To get the list of attachments."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/4150868000004943003/Attachments",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"4150868000004943003",
"Attachments"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 03 May 2021 12:36:51 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-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-03T18:26:34+05:30"
},
{
"key": "clientVersion",
"value": "4002155"
},
{
"key": "clientsubVersion",
"value": "bfb2326744b42e5c869a705645ac0006"
},
{
"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=63072000"
}
],
"cookie": [
],
"body": "{\n \"data\": [\n {\n \"Owner\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"Modified_Time\": \"2021-05-03T17:59:02+05:30\",\n \"File_Name\": \"0f2b4454e6fea3b4c8fcc82e7d2601b0.jpg\",\n \"Created_Time\": \"2021-05-03T17:59:02+05:30\",\n \"Size\": \"563181\",\n \"Parent_Id\": {\n \"name\": \"Brian Dolan\",\n \"id\": \"4150868000004943003\"\n },\n \"$editable\": true,\n \"$sharing_permission\": \"full_access\",\n \"$file_id\": \"1nvs60c82c750d8564edeaf5093ecadff1c9a\",\n \"$type\": \"Attachment\",\n \"$se_module\": \"Leads\",\n \"Modified_By\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$attachment_type\": 0,\n \"$state\": \"save\",\n \"id\": \"4150868000005282007\",\n \"Created_By\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$link_url\": null\n },\n {\n \"Owner\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"Modified_Time\": \"2021-05-03T18:05:58+05:30\",\n \"File_Name\": \"4150868000001144115.zip\",\n \"Created_Time\": \"2021-05-03T18:05:58+05:30\",\n \"Size\": \"335\",\n \"Parent_Id\": {\n \"name\": \"Brian Dolan\",\n \"id\": \"4150868000004943003\"\n },\n \"$editable\": true,\n \"$sharing_permission\": \"full_access\",\n \"$file_id\": \"1nvs652667149a3684a938b5e751e55a280f5\",\n \"$type\": \"Attachment\",\n \"$se_module\": \"Leads\",\n \"Modified_By\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$attachment_type\": 0,\n \"$state\": \"save\",\n \"id\": \"4150868000005277042\",\n \"Created_By\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$link_url\": null\n },\n {\n \"Owner\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"Modified_Time\": \"2021-05-03T18:03:00+05:30\",\n \"File_Name\": \"0f2b4454e6fea3b4c8fcc82e7d2601b0.jpg\",\n \"Created_Time\": \"2021-05-03T18:03:00+05:30\",\n \"Size\": \"563181\",\n \"Parent_Id\": {\n \"name\": \"Brian Dolan\",\n \"id\": \"4150868000004943003\"\n },\n \"$editable\": true,\n \"$sharing_permission\": \"full_access\",\n \"$file_id\": \"1nvs632039a760ec04736b291c070a4a60b11\",\n \"$type\": \"Attachment\",\n \"$se_module\": \"Leads\",\n \"Modified_By\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$attachment_type\": 0,\n \"$state\": \"save\",\n \"id\": \"4150868000005277036\",\n \"Created_By\": {\n \"name\": \"Patricia Boyle\",\n \"id\": \"4150868000000225013\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$link_url\": null\n }\n ],\n \"info\": {\n \"per_page\": 200,\n \"count\": 3,\n \"page\": 1,\n \"more_records\": false\n }\n}"
},
{
"name": "INVALID_MODULE",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Lead/4150868000004943003/Attachments",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Lead",
"4150868000004943003",
"Attachments"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 03 May 2021 12:38:01 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": "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-ACCESSTOKEN-RESET",
"value": "2021-05-03T18:26:34+05:30"
},
{
"key": "clientVersion",
"value": "4002155"
},
{
"key": "clientsubVersion",
"value": "bfb2326744b42e5c869a705645ac0006"
},
{
"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 \"resource_path_index\": 0\n },\n \"message\": \"the module name given seems to be invalid\",\n \"status\": \"error\"\n}"
},
{
"name": "INVALID_URL_PATTERN",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/4150868000004943003Attachments",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"4150868000004943003Attachments"
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 03 May 2021 12:38:26 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-cache"
},
{
"key": "Expires",
"value": "Thu, 01 Jan 1970 00:00:00 GMT"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-ACCESSTOKEN-RESET",
"value": "2021-05-03T18:26:34+05:30"
},
{
"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_REQUEST_METHOD",
"originalRequest": {
"method": "COPY",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/4150868000004943003Attachments",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"4150868000004943003Attachments"
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 03 May 2021 12:38:45 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.1/Leads/4150868000004943003Attachments",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"4150868000004943003Attachments"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 03 May 2021 12:39:01 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": "OAUTH_SCOPE_MISMATCH",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Leads/4150868000004943003/Attachments",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Leads",
"4150868000004943003",
"Attachments"
]
}
},
"status": "Unauthorized",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Mon, 03 May 2021 13:23:04 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}"
}
]
}