Chilkat Online Tools

TCL / Zoho CRM REST APIs / Subforms

Back to Collection Items

load ./chilkat.dll

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

set http [new_CkHttp]

# Adds the "Authorization: Bearer <access_token>" header.
CkHttp_put_AuthToken $http "<access_token>"

set sbResponseBody [new_CkStringBuilder]

set success [CkHttp_QuickGetSb $http "https://domain.com/crm/v2/Leads/{{record_id}}" $sbResponseBody]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0

puts "Response Body:"
puts [CkJsonObject_emit $jResp]

set respStatusCode [CkHttp_get_LastStatus $http]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttp_lastHeader $http]
    puts "Failed."
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $jResp
    exit
}

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

# {
#   "data": [
#     {
#       "Owner": {
#         "name": "Patricia Boyle",
#         "id": "738964000000291009",
#         "email": "patricia.ss@zylker.com"
#       },
#       "Company": null,
#       "Email": null,
#       "$currency_symbol": "Af",
#       "Interested_Leads": null,
#       "Last_Activity_Time": "2021-05-07T13:10:11+00:00",
#       "Industry": null,
#       "$state": "save",
#       "Unsubscribed_Mode": null,
#       "$converted": false,
#       "$process_flow": false,
#       "Exchange_Rate": 1,
#       "Currency": "AFN",
#       "Street": null,
#       "Zip_Code": "1234",
#       "Data_Processing_Basis_Details": null,
#       "id": "738964000002131001",
#       "Data_Source": "Manual",
#       "$approved": true,
#       "$approval": {
#         "delegate": false,
#         "approve": false,
#         "reject": false,
#         "resubmit": false
#       },
#       "$data_source_details": null,
#       "Created_Time": "2021-05-07T06:23:10+00:00",
#       "$editable": true,
#       "City": null,
#       "No_of_Employees": 1000,
#       "State": "Colorado",
#       "Country": null,
#       "Created_By": {
#         "name": "Patricia Boyle",
#         "id": "738964000000291009",
#         "email": "patricia.ss@zylker.com"
#       },
#       "Annual_Revenue": 1,
#       "Secondary_Email": null,
#       "Description": null,
#       "Rating": null,
#       "$review_process": {
#         "approve": false,
#         "reject": false,
#         "resubmit": false
#       },
#       "Website": "https://yaythisworked.com",
#       "Twitter": null,
#       "$canvas_id": null,
#       "Salutation": null,
#       "First_Name": null,
#       "Lead_Status": null,
#       "Full_Name": "sample",
#       "Record_Image": null,
#       "Modified_By": {
#         "name": "Patricia Boyle",
#         "id": "738964000000291009",
#         "email": "patricia.ss@zylker.com"
#       },
#       "$review": null,
#       "Skype_ID": null,
#       "Phone": null,
#       "HIPAA": null,
#       "Email_Opt_Out": false,
#       "Designation": null,
#       "Modified_Time": "2021-05-07T13:10:11+00:00",
#       "$converted_detail": {},
#       "Unsubscribed_Time": null,
#       "Mobile": "9898989898",
#       "$orchestration": false,
#       "$stop_processing": false,
#       "Last_Name": "sample",
#       "$in_merge": false,
#       "Lead_Source": null,
#       "Tag": [
#       ],
#       "Fax": null,
#       "$approval_state": "approved"
#     }
#   ]
# }

# Sample code for parsing the JSON response...
# Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "data"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set Name [CkJsonObject_stringOf $jResp "data[i].Owner.name"]
    set Id [CkJsonObject_stringOf $jResp "data[i].Owner.id"]
    set v_Email [CkJsonObject_stringOf $jResp "data[i].Owner.email"]
    set Company [CkJsonObject_stringOf $jResp "data[i].Company"]
    set v_Email [CkJsonObject_stringOf $jResp "data[i].Email"]
    set Scurrency_symbol [CkJsonObject_stringOf $jResp "data[i].$currency_symbol"]
    set Interested_Leads [CkJsonObject_stringOf $jResp "data[i].Interested_Leads"]
    set Last_Activity_Time [CkJsonObject_stringOf $jResp "data[i].Last_Activity_Time"]
    set Industry [CkJsonObject_stringOf $jResp "data[i].Industry"]
    set Sstate [CkJsonObject_stringOf $jResp "data[i].$state"]
    set Unsubscribed_Mode [CkJsonObject_stringOf $jResp "data[i].Unsubscribed_Mode"]
    set Sconverted [CkJsonObject_BoolOf $jResp "data[i].$converted"]
    set Sprocess_flow [CkJsonObject_BoolOf $jResp "data[i].$process_flow"]
    set Exchange_Rate [CkJsonObject_IntOf $jResp "data[i].Exchange_Rate"]
    set v_Currency [CkJsonObject_stringOf $jResp "data[i].Currency"]
    set Street [CkJsonObject_stringOf $jResp "data[i].Street"]
    set Zip_Code [CkJsonObject_stringOf $jResp "data[i].Zip_Code"]
    set Data_Processing_Basis_Details [CkJsonObject_stringOf $jResp "data[i].Data_Processing_Basis_Details"]
    set id [CkJsonObject_stringOf $jResp "data[i].id"]
    set Data_Source [CkJsonObject_stringOf $jResp "data[i].Data_Source"]
    set Sapproved [CkJsonObject_BoolOf $jResp "data[i].$approved"]
    set Delegate [CkJsonObject_BoolOf $jResp "data[i].$approval.delegate"]
    set Approve [CkJsonObject_BoolOf $jResp "data[i].$approval.approve"]
    set Reject [CkJsonObject_BoolOf $jResp "data[i].$approval.reject"]
    set Resubmit [CkJsonObject_BoolOf $jResp "data[i].$approval.resubmit"]
    set Sdata_source_details [CkJsonObject_stringOf $jResp "data[i].$data_source_details"]
    set Created_Time [CkJsonObject_stringOf $jResp "data[i].Created_Time"]
    set Seditable [CkJsonObject_BoolOf $jResp "data[i].$editable"]
    set City [CkJsonObject_stringOf $jResp "data[i].City"]
    set No_of_Employees [CkJsonObject_IntOf $jResp "data[i].No_of_Employees"]
    set State [CkJsonObject_stringOf $jResp "data[i].State"]
    set Country [CkJsonObject_stringOf $jResp "data[i].Country"]
    set Created_ByName [CkJsonObject_stringOf $jResp "data[i].Created_By.name"]
    set Created_ById [CkJsonObject_stringOf $jResp "data[i].Created_By.id"]
    set Created_ByEmail [CkJsonObject_stringOf $jResp "data[i].Created_By.email"]
    set Annual_Revenue [CkJsonObject_IntOf $jResp "data[i].Annual_Revenue"]
    set Secondary_Email [CkJsonObject_stringOf $jResp "data[i].Secondary_Email"]
    set Description [CkJsonObject_stringOf $jResp "data[i].Description"]
    set Rating [CkJsonObject_stringOf $jResp "data[i].Rating"]
    set Sreview_processApprove [CkJsonObject_BoolOf $jResp "data[i].$review_process.approve"]
    set Sreview_processReject [CkJsonObject_BoolOf $jResp "data[i].$review_process.reject"]
    set Sreview_processResubmit [CkJsonObject_BoolOf $jResp "data[i].$review_process.resubmit"]
    set Website [CkJsonObject_stringOf $jResp "data[i].Website"]
    set Twitter [CkJsonObject_stringOf $jResp "data[i].Twitter"]
    set Scanvas_id [CkJsonObject_stringOf $jResp "data[i].$canvas_id"]
    set Salutation [CkJsonObject_stringOf $jResp "data[i].Salutation"]
    set First_Name [CkJsonObject_stringOf $jResp "data[i].First_Name"]
    set Lead_Status [CkJsonObject_stringOf $jResp "data[i].Lead_Status"]
    set Full_Name [CkJsonObject_stringOf $jResp "data[i].Full_Name"]
    set Record_Image [CkJsonObject_stringOf $jResp "data[i].Record_Image"]
    set Modified_ByName [CkJsonObject_stringOf $jResp "data[i].Modified_By.name"]
    set Modified_ById [CkJsonObject_stringOf $jResp "data[i].Modified_By.id"]
    set Modified_ByEmail [CkJsonObject_stringOf $jResp "data[i].Modified_By.email"]
    set Sreview [CkJsonObject_stringOf $jResp "data[i].$review"]
    set Skype_ID [CkJsonObject_stringOf $jResp "data[i].Skype_ID"]
    set Phone [CkJsonObject_stringOf $jResp "data[i].Phone"]
    set HIPAA [CkJsonObject_stringOf $jResp "data[i].HIPAA"]
    set Email_Opt_Out [CkJsonObject_BoolOf $jResp "data[i].Email_Opt_Out"]
    set Designation [CkJsonObject_stringOf $jResp "data[i].Designation"]
    set Modified_Time [CkJsonObject_stringOf $jResp "data[i].Modified_Time"]
    set Unsubscribed_Time [CkJsonObject_stringOf $jResp "data[i].Unsubscribed_Time"]
    set Mobile [CkJsonObject_stringOf $jResp "data[i].Mobile"]
    set Sorchestration [CkJsonObject_BoolOf $jResp "data[i].$orchestration"]
    set Sstop_processing [CkJsonObject_BoolOf $jResp "data[i].$stop_processing"]
    set Last_Name [CkJsonObject_stringOf $jResp "data[i].Last_Name"]
    set Sin_merge [CkJsonObject_BoolOf $jResp "data[i].$in_merge"]
    set Lead_Source [CkJsonObject_stringOf $jResp "data[i].Lead_Source"]
    set Fax [CkJsonObject_stringOf $jResp "data[i].Fax"]
    set Sapproval_state [CkJsonObject_stringOf $jResp "data[i].$approval_state"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "data[i].Tag"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2/Leads/{{record_id}}

Postman Collection Item JSON

{
  "name": "Subforms",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{access-token}}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{api-domain}}/crm/v2/Leads/{{record_id}}",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2",
        "Leads",
        "{{record_id}}"
      ]
    },
    "description": "To get the subform data in a record."
  },
  "response": [
    {
      "name": "SUCCESS RESPONSE",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/v2/Leads/738964000002131001",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2",
            "Leads",
            "738964000002131001"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 13:16:36 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-11T13:58:39+00:00"
        },
        {
          "key": "clientVersion",
          "value": "4023320"
        },
        {
          "key": "clientsubVersion",
          "value": "4d8b6ee4f7d1d284c930a4e807480c5c"
        },
        {
          "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    \"data\": [\n        {\n            \"Owner\": {\n                \"name\": \"Patricia Boyle\",\n                \"id\": \"738964000000291009\",\n                \"email\": \"patricia.ss@zylker.com\"\n            },\n            \"Company\": null,\n            \"Email\": null,\n            \"$currency_symbol\": \"Af\",\n            \"Interested_Leads\": null,\n            \"Last_Activity_Time\": \"2021-05-07T13:10:11+00:00\",\n            \"Industry\": null,\n            \"$state\": \"save\",\n            \"Unsubscribed_Mode\": null,\n            \"$converted\": false,\n            \"$process_flow\": false,\n            \"Exchange_Rate\": 1,\n            \"Currency\": \"AFN\",\n            \"Street\": null,\n            \"Zip_Code\": \"1234\",\n            \"Data_Processing_Basis_Details\": null,\n            \"id\": \"738964000002131001\",\n            \"Data_Source\": \"Manual\",\n            \"$approved\": true,\n            \"$approval\": {\n                \"delegate\": false,\n                \"approve\": false,\n                \"reject\": false,\n                \"resubmit\": false\n            },\n            \"$data_source_details\": null,\n            \"Created_Time\": \"2021-05-07T06:23:10+00:00\",\n            \"$editable\": true,\n            \"City\": null,\n            \"No_of_Employees\": 1000,\n            \"State\": \"Colorado\",\n            \"Country\": null,\n            \"Created_By\": {\n                \"name\": \"Patricia Boyle\",\n                \"id\": \"738964000000291009\",\n                \"email\": \"patricia.ss@zylker.com\"\n            },\n            \"Annual_Revenue\": 1,\n            \"Secondary_Email\": null,\n            \"Description\": null,\n            \"Rating\": null,\n            \"$review_process\": {\n                \"approve\": false,\n                \"reject\": false,\n                \"resubmit\": false\n            },\n            \"Website\": \"https://yaythisworked.com\",\n            \"Twitter\": null,\n            \"$canvas_id\": null,\n            \"Salutation\": null,\n            \"First_Name\": null,\n            \"Lead_Status\": null,\n            \"Full_Name\": \"sample\",\n            \"Record_Image\": null,\n            \"Modified_By\": {\n                \"name\": \"Patricia Boyle\",\n                \"id\": \"738964000000291009\",\n                \"email\": \"patricia.ss@zylker.com\"\n            },\n            \"$review\": null,\n            \"Skype_ID\": null,\n            \"Phone\": null,\n            \"HIPAA\": null,\n            \"Email_Opt_Out\": false,\n            \"Designation\": null,\n            \"Modified_Time\": \"2021-05-07T13:10:11+00:00\",\n            \"$converted_detail\": {},\n            \"Unsubscribed_Time\": null,\n            \"Mobile\": \"9898989898\",\n            \"$orchestration\": false,\n            \"$stop_processing\": false,\n            \"Last_Name\": \"sample\",\n            \"$in_merge\": false,\n            \"Lead_Source\": null,\n            \"Tag\": [],\n            \"Fax\": null,\n            \"$approval_state\": \"approved\"\n        }\n    ]\n}"
    },
    {
      "name": "INVALID_MODULE",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{api-domain}}/crm/v2/Lead/738964000002131001",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2",
            "Lead",
            "738964000002131001"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 13:16:54 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-11T13:58:39+00:00"
        },
        {
          "key": "clientVersion",
          "value": "4023320"
        },
        {
          "key": "clientsubVersion",
          "value": "4d8b6ee4f7d1d284c930a4e807480c5c"
        },
        {
          "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/Leads/738964000002131001",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2",
            "Leads",
            "738964000002131001"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 13:17:14 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/Leads/738964000002131001",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2",
            "Leads",
            "738964000002131001"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Tue, 11 May 2021 13:17:33 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/Leads/{{record_id}}",
          "host": [
            "{{api-domain}}"
          ],
          "path": [
            "crm",
            "v2",
            "Leads",
            "{{record_id}}"
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "ZGS"
        },
        {
          "key": "Date",
          "value": "Thu, 13 May 2021 06:35:48 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}"
    }
  ]
}