Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Name
string ls_Id
string ls_V_Email
string ls_Scurrency_symbol
string ls_Account_Type
string ls_SIC_Code
string ls_Last_Activity_Time
string ls_Industry
string ls_Account_Site
string ls_Sstate
integer li_Sprocess_flow
integer li_Exchange_Rate
string ls_Billing_Country
string ls_V_Currency
string ls_Id
integer li_Sapproved
integer li_Delegate
integer li_Approve
integer li_Reject
integer li_Resubmit
string ls_Billing_Street
string ls_Created_Time
integer li_Seditable
string ls_Billing_Code
string ls_Shipping_City
string ls_Shipping_Country
string ls_Shipping_Code
string ls_Billing_City
string ls_Created_ByName
string ls_Created_ById
string ls_Created_ByEmail
integer li_Annual_Revenue
string ls_Shipping_Street
string ls_Territory_updated_time
string ls_Ownership
string ls_Description
string ls_Rating
string ls_Shipping_State
integer li_Sreview_processApprove
integer li_Sreview_processReject
integer li_Sreview_processResubmit
string ls_Website
string ls_Employees
string ls_Record_Image
string ls_Modified_ByName
string ls_Modified_ById
string ls_Modified_ByEmail
string ls_Sreview
string ls_Phone
string ls_Account_Name
string ls_Account_Number
string ls_Ticker_Symbol
string ls_Modified_Time
integer li_Sorchestration
string ls_Parent_Account
integer li_Sin_merge
string ls_Billing_State
string ls_Fax
string ls_Sapproval_state
integer j
integer li_Count_j
string ls_StrVal
integer li_Per_page
integer li_Count
integer li_Page
integer li_More_records
integer i
integer li_Count_i
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Http.QuickGetSb("https://domain.com/crm/v2/Accounts",loo_SbResponseBody)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_SbResponseBody
return
end if
loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Http.LastHeader
Write-Debug "Failed."
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
// 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"
// },
// "$currency_symbol": "Af",
// "Account_Type": null,
// "SIC_Code": null,
// "Last_Activity_Time": "2021-05-07T06:19:49+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 Boyle",
// "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 Boyle",
// "id": "738964000000291009",
// "email": "patricia.ss@zylker.com"
// },
// "$review": null,
// "Phone": null,
// "Account_Name": "Villa Margarita",
// "Account_Number": "0",
// "Ticker_Symbol": null,
// "Modified_Time": "2021-05-07T06:19:48+00:00",
// "Territories": [
// "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
li_Per_page = loo_JResp.IntOf("info.per_page")
li_Count = loo_JResp.IntOf("info.count")
li_Page = loo_JResp.IntOf("info.page")
li_More_records = loo_JResp.BoolOf("info.more_records")
i = 0
li_Count_i = loo_JResp.SizeOfArray("data")
do while i < li_Count_i
loo_JResp.I = i
ls_Name = loo_JResp.StringOf("data[i].Owner.name")
ls_Id = loo_JResp.StringOf("data[i].Owner.id")
ls_V_Email = loo_JResp.StringOf("data[i].Owner.email")
ls_Scurrency_symbol = loo_JResp.StringOf("data[i].$currency_symbol")
ls_Account_Type = loo_JResp.StringOf("data[i].Account_Type")
ls_SIC_Code = loo_JResp.StringOf("data[i].SIC_Code")
ls_Last_Activity_Time = loo_JResp.StringOf("data[i].Last_Activity_Time")
ls_Industry = loo_JResp.StringOf("data[i].Industry")
ls_Account_Site = loo_JResp.StringOf("data[i].Account_Site")
ls_Sstate = loo_JResp.StringOf("data[i].$state")
li_Sprocess_flow = loo_JResp.BoolOf("data[i].$process_flow")
li_Exchange_Rate = loo_JResp.IntOf("data[i].Exchange_Rate")
ls_Billing_Country = loo_JResp.StringOf("data[i].Billing_Country")
ls_V_Currency = loo_JResp.StringOf("data[i].Currency")
ls_Id = loo_JResp.StringOf("data[i].id")
li_Sapproved = loo_JResp.BoolOf("data[i].$approved")
li_Delegate = loo_JResp.BoolOf("data[i].$approval.delegate")
li_Approve = loo_JResp.BoolOf("data[i].$approval.approve")
li_Reject = loo_JResp.BoolOf("data[i].$approval.reject")
li_Resubmit = loo_JResp.BoolOf("data[i].$approval.resubmit")
ls_Billing_Street = loo_JResp.StringOf("data[i].Billing_Street")
ls_Created_Time = loo_JResp.StringOf("data[i].Created_Time")
li_Seditable = loo_JResp.BoolOf("data[i].$editable")
ls_Billing_Code = loo_JResp.StringOf("data[i].Billing_Code")
ls_Shipping_City = loo_JResp.StringOf("data[i].Shipping_City")
ls_Shipping_Country = loo_JResp.StringOf("data[i].Shipping_Country")
ls_Shipping_Code = loo_JResp.StringOf("data[i].Shipping_Code")
ls_Billing_City = loo_JResp.StringOf("data[i].Billing_City")
ls_Created_ByName = loo_JResp.StringOf("data[i].Created_By.name")
ls_Created_ById = loo_JResp.StringOf("data[i].Created_By.id")
ls_Created_ByEmail = loo_JResp.StringOf("data[i].Created_By.email")
li_Annual_Revenue = loo_JResp.IntOf("data[i].Annual_Revenue")
ls_Shipping_Street = loo_JResp.StringOf("data[i].Shipping_Street")
ls_Territory_updated_time = loo_JResp.StringOf("data[i].territory_updated_time")
ls_Ownership = loo_JResp.StringOf("data[i].Ownership")
ls_Description = loo_JResp.StringOf("data[i].Description")
ls_Rating = loo_JResp.StringOf("data[i].Rating")
ls_Shipping_State = loo_JResp.StringOf("data[i].Shipping_State")
li_Sreview_processApprove = loo_JResp.BoolOf("data[i].$review_process.approve")
li_Sreview_processReject = loo_JResp.BoolOf("data[i].$review_process.reject")
li_Sreview_processResubmit = loo_JResp.BoolOf("data[i].$review_process.resubmit")
ls_Website = loo_JResp.StringOf("data[i].Website")
ls_Employees = loo_JResp.StringOf("data[i].Employees")
ls_Record_Image = loo_JResp.StringOf("data[i].Record_Image")
ls_Modified_ByName = loo_JResp.StringOf("data[i].Modified_By.name")
ls_Modified_ById = loo_JResp.StringOf("data[i].Modified_By.id")
ls_Modified_ByEmail = loo_JResp.StringOf("data[i].Modified_By.email")
ls_Sreview = loo_JResp.StringOf("data[i].$review")
ls_Phone = loo_JResp.StringOf("data[i].Phone")
ls_Account_Name = loo_JResp.StringOf("data[i].Account_Name")
ls_Account_Number = loo_JResp.StringOf("data[i].Account_Number")
ls_Ticker_Symbol = loo_JResp.StringOf("data[i].Ticker_Symbol")
ls_Modified_Time = loo_JResp.StringOf("data[i].Modified_Time")
li_Sorchestration = loo_JResp.BoolOf("data[i].$orchestration")
ls_Parent_Account = loo_JResp.StringOf("data[i].Parent_Account")
li_Sin_merge = loo_JResp.BoolOf("data[i].$in_merge")
ls_Billing_State = loo_JResp.StringOf("data[i].Billing_State")
ls_Fax = loo_JResp.StringOf("data[i].Fax")
ls_Sapproval_state = loo_JResp.StringOf("data[i].$approval_state")
j = 0
li_Count_j = loo_JResp.SizeOfArray("data[i].Territories")
do while j < li_Count_j
loo_JResp.J = j
ls_StrVal = loo_JResp.StringOf("data[i].Territories[j]")
j = j + 1
loop
j = 0
li_Count_j = loo_JResp.SizeOfArray("data[i].Tag")
do while j < li_Count_j
loo_JResp.J = j
j = j + 1
loop
i = i + 1
loop
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://domain.com/crm/v2/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/Accounts",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"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/Accounts?territory_id=738964000001977355",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"Accounts"
],
"query": [
{
"key": "territory_id",
"value": "738964000001977355"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "ZGS"
},
{
"key": "Date",
"value": "Tue, 11 May 2021 12:37:14 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-11T12:57:36+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 \"$currency_symbol\": \"Af\",\n \"Account_Type\": null,\n \"SIC_Code\": null,\n \"Last_Activity_Time\": \"2021-05-07T06:19:49+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 Boyle\",\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 Boyle\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$review\": null,\n \"Phone\": null,\n \"Account_Name\": \"Villa Margarita\",\n \"Account_Number\": \"0\",\n \"Ticker_Symbol\": null,\n \"Modified_Time\": \"2021-05-07T06:19:48+00:00\",\n \"Territories\": [\n \"South Zone\"\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/Accounts?territory_id=738964000001977355&include_child=true",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"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": "Tue, 11 May 2021 12:37:35 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-11T12:57:36+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 \"$currency_symbol\": \"Af\",\n \"Account_Type\": null,\n \"SIC_Code\": null,\n \"Last_Activity_Time\": \"2021-05-07T06:19:49+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 Boyle\",\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 Boyle\",\n \"id\": \"738964000000291009\",\n \"email\": \"patricia.ss@zylker.com\"\n },\n \"$review\": null,\n \"Phone\": null,\n \"Account_Name\": \"Villa Margarita\",\n \"Account_Number\": \"0\",\n \"Ticker_Symbol\": null,\n \"Modified_Time\": \"2021-05-07T06:19:48+00:00\",\n \"Territories\": [\n \"South Zone\"\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}"
}
]
}