Chilkat Online Tools

VB.NET / Zoho CRM REST APIs / Accounts

Back to Collection Items

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

Dim http As New Chilkat.Http
Dim success As Boolean

' Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>"

Dim sbResponseBody As New Chilkat.StringBuilder
success = http.QuickGetSb("https://domain.com/crm/v2/Accounts",sbResponseBody)
If (success = False) Then
    Debug.WriteLine(http.LastErrorText)
    Exit Sub
End If


Dim jResp As New Chilkat.JsonObject
jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

Debug.WriteLine("Response Body:")
Debug.WriteLine(jResp.Emit())

Dim respStatusCode As Integer = http.LastStatus
Debug.WriteLine("Response Status Code = " & respStatusCode)
If (respStatusCode >= 400) Then
    Debug.WriteLine("Response Header:")
    Debug.WriteLine(http.LastHeader)
    Debug.WriteLine("Failed.")
    Exit Sub
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



Dim Name As String
Dim Id As String
Dim v_Email As String
Dim Scurrency_symbol As String
Dim Account_Type As String
Dim SIC_Code As String
Dim Last_Activity_Time As String
Dim Industry As String
Dim Account_Site As String
Dim Sstate As String
Dim Sprocess_flow As Boolean
Dim Exchange_Rate As Integer
Dim Billing_Country As String
Dim v_Currency As String
Dim id As String
Dim Sapproved As Boolean
Dim Delegate As Boolean
Dim Approve As Boolean
Dim Reject As Boolean
Dim Resubmit As Boolean
Dim Billing_Street As String
Dim Created_Time As String
Dim Seditable As Boolean
Dim Billing_Code As String
Dim Shipping_City As String
Dim Shipping_Country As String
Dim Shipping_Code As String
Dim Billing_City As String
Dim Created_ByName As String
Dim Created_ById As String
Dim Created_ByEmail As String
Dim Annual_Revenue As Integer
Dim Shipping_Street As String
Dim territory_updated_time As String
Dim Ownership As String
Dim Description As String
Dim Rating As String
Dim Shipping_State As String
Dim Sreview_processApprove As Boolean
Dim Sreview_processReject As Boolean
Dim Sreview_processResubmit As Boolean
Dim Website As String
Dim Employees As String
Dim Record_Image As String
Dim Modified_ByName As String
Dim Modified_ById As String
Dim Modified_ByEmail As String
Dim Sreview As String
Dim Phone As String
Dim Account_Name As String
Dim Account_Number As String
Dim Ticker_Symbol As String
Dim Modified_Time As String
Dim Sorchestration As Boolean
Dim Parent_Account As String
Dim Sin_merge As Boolean
Dim Billing_State As String
Dim Fax As String
Dim Sapproval_state As String
Dim j As Integer
Dim count_j As Integer
Dim strVal As String

Dim Per_page As Integer = jResp.IntOf("info.per_page")
Dim Count As Integer = jResp.IntOf("info.count")
Dim Page As Integer = jResp.IntOf("info.page")
Dim More_records As Boolean = jResp.BoolOf("info.more_records")
Dim i As Integer = 0
Dim count_i As Integer = jResp.SizeOfArray("data")
While i < count_i
    jResp.I = i
    Name = jResp.StringOf("data[i].Owner.name")
    Id = jResp.StringOf("data[i].Owner.id")
    v_Email = jResp.StringOf("data[i].Owner.email")
    Scurrency_symbol = jResp.StringOf("data[i].$currency_symbol")
    Account_Type = jResp.StringOf("data[i].Account_Type")
    SIC_Code = jResp.StringOf("data[i].SIC_Code")
    Last_Activity_Time = jResp.StringOf("data[i].Last_Activity_Time")
    Industry = jResp.StringOf("data[i].Industry")
    Account_Site = jResp.StringOf("data[i].Account_Site")
    Sstate = jResp.StringOf("data[i].$state")
    Sprocess_flow = jResp.BoolOf("data[i].$process_flow")
    Exchange_Rate = jResp.IntOf("data[i].Exchange_Rate")
    Billing_Country = jResp.StringOf("data[i].Billing_Country")
    v_Currency = jResp.StringOf("data[i].Currency")
    id = jResp.StringOf("data[i].id")
    Sapproved = jResp.BoolOf("data[i].$approved")
    Delegate = jResp.BoolOf("data[i].$approval.delegate")
    Approve = jResp.BoolOf("data[i].$approval.approve")
    Reject = jResp.BoolOf("data[i].$approval.reject")
    Resubmit = jResp.BoolOf("data[i].$approval.resubmit")
    Billing_Street = jResp.StringOf("data[i].Billing_Street")
    Created_Time = jResp.StringOf("data[i].Created_Time")
    Seditable = jResp.BoolOf("data[i].$editable")
    Billing_Code = jResp.StringOf("data[i].Billing_Code")
    Shipping_City = jResp.StringOf("data[i].Shipping_City")
    Shipping_Country = jResp.StringOf("data[i].Shipping_Country")
    Shipping_Code = jResp.StringOf("data[i].Shipping_Code")
    Billing_City = jResp.StringOf("data[i].Billing_City")
    Created_ByName = jResp.StringOf("data[i].Created_By.name")
    Created_ById = jResp.StringOf("data[i].Created_By.id")
    Created_ByEmail = jResp.StringOf("data[i].Created_By.email")
    Annual_Revenue = jResp.IntOf("data[i].Annual_Revenue")
    Shipping_Street = jResp.StringOf("data[i].Shipping_Street")
    territory_updated_time = jResp.StringOf("data[i].territory_updated_time")
    Ownership = jResp.StringOf("data[i].Ownership")
    Description = jResp.StringOf("data[i].Description")
    Rating = jResp.StringOf("data[i].Rating")
    Shipping_State = jResp.StringOf("data[i].Shipping_State")
    Sreview_processApprove = jResp.BoolOf("data[i].$review_process.approve")
    Sreview_processReject = jResp.BoolOf("data[i].$review_process.reject")
    Sreview_processResubmit = jResp.BoolOf("data[i].$review_process.resubmit")
    Website = jResp.StringOf("data[i].Website")
    Employees = jResp.StringOf("data[i].Employees")
    Record_Image = jResp.StringOf("data[i].Record_Image")
    Modified_ByName = jResp.StringOf("data[i].Modified_By.name")
    Modified_ById = jResp.StringOf("data[i].Modified_By.id")
    Modified_ByEmail = jResp.StringOf("data[i].Modified_By.email")
    Sreview = jResp.StringOf("data[i].$review")
    Phone = jResp.StringOf("data[i].Phone")
    Account_Name = jResp.StringOf("data[i].Account_Name")
    Account_Number = jResp.StringOf("data[i].Account_Number")
    Ticker_Symbol = jResp.StringOf("data[i].Ticker_Symbol")
    Modified_Time = jResp.StringOf("data[i].Modified_Time")
    Sorchestration = jResp.BoolOf("data[i].$orchestration")
    Parent_Account = jResp.StringOf("data[i].Parent_Account")
    Sin_merge = jResp.BoolOf("data[i].$in_merge")
    Billing_State = jResp.StringOf("data[i].Billing_State")
    Fax = jResp.StringOf("data[i].Fax")
    Sapproval_state = jResp.StringOf("data[i].$approval_state")
    j = 0
    count_j = jResp.SizeOfArray("data[i].Territories")
    While j < count_j
        jResp.J = j
        strVal = jResp.StringOf("data[i].Territories[j]")
        j = j + 1
    End While
    j = 0
    count_j = jResp.SizeOfArray("data[i].Tag")
    While j < count_j
        jResp.J = j
        j = j + 1
    End While
    i = i + 1
End While

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}"
    }
  ]
}