Back to Collection Items
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess
; Adds the "Authorization: Bearer <access_token>" header.
$oHttp.AuthToken = "<access_token>"
$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://domain.com/crm/v2.1/Accounts",$oSbResponseBody)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oHttp.LastHeader & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)
; {
; "data": [
; {
; "Owner": {
; "name": "patricia patricia",
; "id": "738964000000291009",
; "email": "patricia.ss@zylker.com"
; },
; "$currency_symbol": "Af",
; "Account_Type": null,
; "SIC_Code": null,
; "$sharing_permission": "full_access",
; "Last_Activity_Time": "2021-04-21T08:53:58+00:00",
; "Industry": null,
; "Account_Site": null,
; "$state": "save",
; "$process_flow": false,
; "Exchange_Rate": 1,
; "Billing_Country": null,
; "Currency": "AFN",
; "id": "738964000002058030",
; "$approved": true,
; "$approval": {
; "delegate": false,
; "approve": false,
; "reject": false,
; "resubmit": false
; },
; "Billing_Street": null,
; "Created_Time": "2021-04-21T08:53:58+00:00",
; "$editable": true,
; "Billing_Code": "1234",
; "Shipping_City": null,
; "Shipping_Country": null,
; "Shipping_Code": null,
; "Billing_City": null,
; "Created_By": {
; "name": "patricia patricia",
; "id": "738964000000291009",
; "email": "patricia.ss@zylker.com"
; },
; "Annual_Revenue": 1,
; "Shipping_Street": null,
; "territory_updated_time": null,
; "Ownership": null,
; "Description": null,
; "Rating": null,
; "Shipping_State": null,
; "$review_process": {
; "approve": false,
; "reject": false,
; "resubmit": false
; },
; "Website": "https://yaythisworked.com",
; "Employees": null,
; "Record_Image": null,
; "Modified_By": {
; "name": "patricia patricia",
; "id": "738964000000291009",
; "email": "patricia.ss@zylker.com"
; },
; "$review": null,
; "Phone": null,
; "Account_Name": "Zylker",
; "Account_Number": "0",
; "Ticker_Symbol": null,
; "Modified_Time": "2021-04-21T08:53:58+00:00",
; "Territories": [
; {
; "$assigned": "automatically",
; "$assigned_time": "2021-04-21T08:54:13+00:00",
; "id": "738964000001977355",
; "$assigned_by": null,
; "Name": "South Zone"
; }
; ],
; "$orchestration": false,
; "Parent_Account": null,
; "$in_merge": false,
; "Billing_State": "Colorado",
; "Tag": [
; ],
; "Fax": null,
; "$approval_state": "approved"
; }
; ],
; "info": {
; "per_page": 200,
; "count": 1,
; "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
Local $sName
Local $sId
Local $sV_Email
Local $sScurrency_symbol
Local $sAccount_Type
Local $sSIC_Code
Local $sSsharing_permission
Local $sLast_Activity_Time
Local $sIndustry
Local $sAccount_Site
Local $sSstate
Local $bSprocess_flow
Local $iExchange_Rate
Local $sBilling_Country
Local $sV_Currency
Local $sId
Local $bSapproved
Local $bDelegate
Local $bApprove
Local $bReject
Local $bResubmit
Local $sBilling_Street
Local $sCreated_Time
Local $bSeditable
Local $sBilling_Code
Local $sShipping_City
Local $sShipping_Country
Local $sShipping_Code
Local $sBilling_City
Local $sCreated_ByName
Local $sCreated_ById
Local $sCreated_ByEmail
Local $iAnnual_Revenue
Local $sShipping_Street
Local $sTerritory_updated_time
Local $sOwnership
Local $sDescription
Local $sRating
Local $sShipping_State
Local $bSreview_processApprove
Local $bSreview_processReject
Local $bSreview_processResubmit
Local $sWebsite
Local $sEmployees
Local $sRecord_Image
Local $sModified_ByName
Local $sModified_ById
Local $sModified_ByEmail
Local $sSreview
Local $sPhone
Local $sAccount_Name
Local $sAccount_Number
Local $sTicker_Symbol
Local $sModified_Time
Local $bSorchestration
Local $sParent_Account
Local $bSin_merge
Local $sBilling_State
Local $sFax
Local $sSapproval_state
Local $iJ
Local $iCount_j
Local $sSassigned
Local $sSassigned_time
Local $sSassigned_by
Local $iPer_page = $oJResp.IntOf("info.per_page")
Local $iCount = $oJResp.IntOf("info.count")
Local $iPage = $oJResp.IntOf("info.page")
Local $bMore_records = $oJResp.BoolOf("info.more_records")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("data")
While $i < $iCount_i
$oJResp.I = $i
$sName = $oJResp.StringOf("data[i].Owner.name")
$sId = $oJResp.StringOf("data[i].Owner.id")
$sV_Email = $oJResp.StringOf("data[i].Owner.email")
$sScurrency_symbol = $oJResp.StringOf("data[i].$currency_symbol")
$sAccount_Type = $oJResp.StringOf("data[i].Account_Type")
$sSIC_Code = $oJResp.StringOf("data[i].SIC_Code")
$sSsharing_permission = $oJResp.StringOf("data[i].$sharing_permission")
$sLast_Activity_Time = $oJResp.StringOf("data[i].Last_Activity_Time")
$sIndustry = $oJResp.StringOf("data[i].Industry")
$sAccount_Site = $oJResp.StringOf("data[i].Account_Site")
$sSstate = $oJResp.StringOf("data[i].$state")
$bSprocess_flow = $oJResp.BoolOf("data[i].$process_flow")
$iExchange_Rate = $oJResp.IntOf("data[i].Exchange_Rate")
$sBilling_Country = $oJResp.StringOf("data[i].Billing_Country")
$sV_Currency = $oJResp.StringOf("data[i].Currency")
$sId = $oJResp.StringOf("data[i].id")
$bSapproved = $oJResp.BoolOf("data[i].$approved")
$bDelegate = $oJResp.BoolOf("data[i].$approval.delegate")
$bApprove = $oJResp.BoolOf("data[i].$approval.approve")
$bReject = $oJResp.BoolOf("data[i].$approval.reject")
$bResubmit = $oJResp.BoolOf("data[i].$approval.resubmit")
$sBilling_Street = $oJResp.StringOf("data[i].Billing_Street")
$sCreated_Time = $oJResp.StringOf("data[i].Created_Time")
$bSeditable = $oJResp.BoolOf("data[i].$editable")
$sBilling_Code = $oJResp.StringOf("data[i].Billing_Code")
$sShipping_City = $oJResp.StringOf("data[i].Shipping_City")
$sShipping_Country = $oJResp.StringOf("data[i].Shipping_Country")
$sShipping_Code = $oJResp.StringOf("data[i].Shipping_Code")
$sBilling_City = $oJResp.StringOf("data[i].Billing_City")
$sCreated_ByName = $oJResp.StringOf("data[i].Created_By.name")
$sCreated_ById = $oJResp.StringOf("data[i].Created_By.id")
$sCreated_ByEmail = $oJResp.StringOf("data[i].Created_By.email")
$iAnnual_Revenue = $oJResp.IntOf("data[i].Annual_Revenue")
$sShipping_Street = $oJResp.StringOf("data[i].Shipping_Street")
$sTerritory_updated_time = $oJResp.StringOf("data[i].territory_updated_time")
$sOwnership = $oJResp.StringOf("data[i].Ownership")
$sDescription = $oJResp.StringOf("data[i].Description")
$sRating = $oJResp.StringOf("data[i].Rating")
$sShipping_State = $oJResp.StringOf("data[i].Shipping_State")
$bSreview_processApprove = $oJResp.BoolOf("data[i].$review_process.approve")
$bSreview_processReject = $oJResp.BoolOf("data[i].$review_process.reject")
$bSreview_processResubmit = $oJResp.BoolOf("data[i].$review_process.resubmit")
$sWebsite = $oJResp.StringOf("data[i].Website")
$sEmployees = $oJResp.StringOf("data[i].Employees")
$sRecord_Image = $oJResp.StringOf("data[i].Record_Image")
$sModified_ByName = $oJResp.StringOf("data[i].Modified_By.name")
$sModified_ById = $oJResp.StringOf("data[i].Modified_By.id")
$sModified_ByEmail = $oJResp.StringOf("data[i].Modified_By.email")
$sSreview = $oJResp.StringOf("data[i].$review")
$sPhone = $oJResp.StringOf("data[i].Phone")
$sAccount_Name = $oJResp.StringOf("data[i].Account_Name")
$sAccount_Number = $oJResp.StringOf("data[i].Account_Number")
$sTicker_Symbol = $oJResp.StringOf("data[i].Ticker_Symbol")
$sModified_Time = $oJResp.StringOf("data[i].Modified_Time")
$bSorchestration = $oJResp.BoolOf("data[i].$orchestration")
$sParent_Account = $oJResp.StringOf("data[i].Parent_Account")
$bSin_merge = $oJResp.BoolOf("data[i].$in_merge")
$sBilling_State = $oJResp.StringOf("data[i].Billing_State")
$sFax = $oJResp.StringOf("data[i].Fax")
$sSapproval_state = $oJResp.StringOf("data[i].$approval_state")
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("data[i].Territories")
While $iJ < $iCount_j
$oJResp.J = $iJ
$sSassigned = $oJResp.StringOf("data[i].Territories[j].$assigned")
$sSassigned_time = $oJResp.StringOf("data[i].Territories[j].$assigned_time")
$sId = $oJResp.StringOf("data[i].Territories[j].id")
$sSassigned_by = $oJResp.StringOf("data[i].Territories[j].$assigned_by")
$sName = $oJResp.StringOf("data[i].Territories[j].Name")
$iJ = $iJ + 1
Wend
$iJ = 0
$iCount_j = $oJResp.SizeOfArray("data[i].Tag")
While $iJ < $iCount_j
$oJResp.J = $iJ
$iJ = $iJ + 1
Wend
$i = $i + 1
Wend
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2.1/Accounts
Postman Collection Item JSON
{
"name": "Accounts",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Accounts",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Accounts"
]
},
"description": "To get the list of available records in the Accounts module."
},
"response": [
{
"name": "P8: territory_id",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Accounts?territory_id=738964000001977355",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Accounts"
],
"query": [
{
"key": "territory_id",
"value": "738964000001977355"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 05 May 2021 06:44:50 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-05T07:39:40+00:00"
},
{
"key": "clientVersion",
"value": "4009533"
},
{
"key": "clientsubVersion",
"value": "cfa914635a0a376a1322139140e8bf37"
},
{
"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 patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$currency_symbol\": \"Af\",\n \"Account_Type\": null,\n \"SIC_Code\": null,\n \"$sharing_permission\": \"full_access\",\n \"Last_Activity_Time\": \"2021-04-21T08:53:58+00:00\",\n \"Industry\": null,\n \"Account_Site\": null,\n \"$state\": \"save\",\n \"$process_flow\": false,\n \"Exchange_Rate\": 1,\n \"Billing_Country\": null,\n \"Currency\": \"AFN\",\n \"id\": \"738964000002058030\",\n \"$approved\": true,\n \"$approval\": {\n \"delegate\": false,\n \"approve\": false,\n \"reject\": false,\n \"resubmit\": false\n },\n \"Billing_Street\": null,\n \"Created_Time\": \"2021-04-21T08:53:58+00:00\",\n \"$editable\": true,\n \"Billing_Code\": \"1234\",\n \"Shipping_City\": null,\n \"Shipping_Country\": null,\n \"Shipping_Code\": null,\n \"Billing_City\": null,\n \"Created_By\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"Annual_Revenue\": 1,\n \"Shipping_Street\": null,\n \"territory_updated_time\": null,\n \"Ownership\": null,\n \"Description\": null,\n \"Rating\": null,\n \"Shipping_State\": null,\n \"$review_process\": {\n \"approve\": false,\n \"reject\": false,\n \"resubmit\": false\n },\n \"Website\": \"https://yaythisworked.com\",\n \"Employees\": null,\n \"Record_Image\": null,\n \"Modified_By\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$review\": null,\n \"Phone\": null,\n \"Account_Name\": \"Zylker\",\n \"Account_Number\": \"0\",\n \"Ticker_Symbol\": null,\n \"Modified_Time\": \"2021-04-21T08:53:58+00:00\",\n \"Territories\": [\n {\n \"$assigned\": \"automatically\",\n \"$assigned_time\": \"2021-04-21T08:54:13+00:00\",\n \"id\": \"738964000001977355\",\n \"$assigned_by\": null,\n \"Name\": \"South Zone\"\n }\n ],\n \"$orchestration\": false,\n \"Parent_Account\": null,\n \"$in_merge\": false,\n \"Billing_State\": \"Colorado\",\n \"Tag\": [],\n \"Fax\": null,\n \"$approval_state\": \"approved\"\n }\n ],\n \"info\": {\n \"per_page\": 200,\n \"count\": 1,\n \"page\": 1,\n \"more_records\": false\n }\n}"
},
{
"name": "P9: include_child",
"originalRequest": {
"method": "GET",
"header": [
],
"url": {
"raw": "{{api-domain}}/crm/v2.1/Accounts?territory_id=738964000001977355&include_child=true",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Accounts"
],
"query": [
{
"key": "territory_id",
"value": "738964000001977355"
},
{
"key": "include_child",
"value": "true"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Wed, 05 May 2021 06:45:34 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-05T07:39:40+00:00"
},
{
"key": "clientVersion",
"value": "4009533"
},
{
"key": "clientsubVersion",
"value": "cfa914635a0a376a1322139140e8bf37"
},
{
"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 patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$currency_symbol\": \"Af\",\n \"Account_Type\": null,\n \"SIC_Code\": null,\n \"$sharing_permission\": \"full_access\",\n \"Last_Activity_Time\": \"2021-04-21T08:53:58+00:00\",\n \"Industry\": null,\n \"Account_Site\": null,\n \"$state\": \"save\",\n \"$process_flow\": false,\n \"Exchange_Rate\": 1,\n \"Billing_Country\": null,\n \"Currency\": \"AFN\",\n \"id\": \"738964000002058030\",\n \"$approved\": true,\n \"$approval\": {\n \"delegate\": false,\n \"approve\": false,\n \"reject\": false,\n \"resubmit\": false\n },\n \"Billing_Street\": null,\n \"Created_Time\": \"2021-04-21T08:53:58+00:00\",\n \"$editable\": true,\n \"Billing_Code\": \"1234\",\n \"Shipping_City\": null,\n \"Shipping_Country\": null,\n \"Shipping_Code\": null,\n \"Billing_City\": null,\n \"Created_By\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"Annual_Revenue\": 1,\n \"Shipping_Street\": null,\n \"territory_updated_time\": null,\n \"Ownership\": null,\n \"Description\": null,\n \"Rating\": null,\n \"Shipping_State\": null,\n \"$review_process\": {\n \"approve\": false,\n \"reject\": false,\n \"resubmit\": false\n },\n \"Website\": \"https://yaythisworked.com\",\n \"Employees\": null,\n \"Record_Image\": null,\n \"Modified_By\": {\n \"name\": \"patricia patricia\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$review\": null,\n \"Phone\": null,\n \"Account_Name\": \"Zylker\",\n \"Account_Number\": \"0\",\n \"Ticker_Symbol\": null,\n \"Modified_Time\": \"2021-04-21T08:53:58+00:00\",\n \"Territories\": [\n {\n \"$assigned\": \"automatically\",\n \"$assigned_time\": \"2021-04-21T08:54:13+00:00\",\n \"id\": \"738964000001977355\",\n \"$assigned_by\": null,\n \"Name\": \"South Zone\"\n }\n ],\n \"$orchestration\": false,\n \"Parent_Account\": null,\n \"$in_merge\": false,\n \"Billing_State\": \"Colorado\",\n \"Tag\": [],\n \"Fax\": null,\n \"$approval_state\": \"approved\"\n }\n ],\n \"info\": {\n \"per_page\": 200,\n \"count\": 1,\n \"page\": 1,\n \"more_records\": false\n }\n}"
}
]
}