Chilkat Online Tools

PowerBuilder / easybill REST API / Fetch customer contact list

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_City
string ls_Street
string ls_State
string ls_Company_name
string ls_Country
string ls_Department
string ls_Fax
string ls_First_name
string ls_Id
string ls_Last_name
string ls_Login_id
string ls_Mobile
string ls_Note
integer li_Personal
string ls_Phone_1
string ls_Phone_2
string ls_Salutation
string ls_Suffix_1
string ls_Suffix_2
string ls_Title
string ls_Zip_code
string ls_Created_at
string ls_Updated_at
string ls_Page
string ls_Pages
string ls_Limit
string ls_Total
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
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
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

loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")

loo_QueryParams.UpdateString("limit","<integer>")
loo_QueryParams.UpdateString("page","<integer>")

loo_Http.SetRequestHeader("Authorization","{{apiKey}}")
loo_Http.SetRequestHeader("Accept","application/json")

loo_Resp = loo_Http.QuickRequestParams("GET","https://api.easybill.de/rest/v1/customers/:customerId/contacts",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
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_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

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

// {
//   "page": "<integer>",
//   "pages": "<integer>",
//   "limit": "<integer>",
//   "total": "<integer>",
//   "items": [
//     {
//       "city": "<string>",
//       "street": "<string>",
//       "state": "<string>",
//       "company_name": "<string>",
//       "country": "<string>",
//       "department": null,
//       "fax": null,
//       "first_name": null,
//       "id": "<long>",
//       "last_name": null,
//       "login_id": "<long>",
//       "mobile": null,
//       "note": null,
//       "personal": false,
//       "phone_1": null,
//       "phone_2": null,
//       "salutation": "<integer>",
//       "suffix_1": null,
//       "suffix_2": null,
//       "title": null,
//       "zip_code": null,
//       "created_at": "<string>",
//       "updated_at": "<string>"
//     },
//     {
//       "city": "<string>",
//       "street": "<string>",
//       "state": "<string>",
//       "company_name": "<string>",
//       "country": "<string>",
//       "department": null,
//       "fax": null,
//       "first_name": null,
//       "id": "<long>",
//       "last_name": null,
//       "login_id": "<long>",
//       "mobile": null,
//       "note": null,
//       "personal": false,
//       "phone_1": null,
//       "phone_2": null,
//       "salutation": "<integer>",
//       "suffix_1": null,
//       "suffix_2": null,
//       "title": null,
//       "zip_code": null,
//       "created_at": "<string>",
//       "updated_at": "<string>"
//     }
//   ]
// }

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

ls_Page = loo_JResp.StringOf("page")
ls_Pages = loo_JResp.StringOf("pages")
ls_Limit = loo_JResp.StringOf("limit")
ls_Total = loo_JResp.StringOf("total")
i = 0
li_Count_i = loo_JResp.SizeOfArray("items")
do while i < li_Count_i
    loo_JResp.I = i
    ls_City = loo_JResp.StringOf("items[i].city")
    ls_Street = loo_JResp.StringOf("items[i].street")
    ls_State = loo_JResp.StringOf("items[i].state")
    ls_Company_name = loo_JResp.StringOf("items[i].company_name")
    ls_Country = loo_JResp.StringOf("items[i].country")
    ls_Department = loo_JResp.StringOf("items[i].department")
    ls_Fax = loo_JResp.StringOf("items[i].fax")
    ls_First_name = loo_JResp.StringOf("items[i].first_name")
    ls_Id = loo_JResp.StringOf("items[i].id")
    ls_Last_name = loo_JResp.StringOf("items[i].last_name")
    ls_Login_id = loo_JResp.StringOf("items[i].login_id")
    ls_Mobile = loo_JResp.StringOf("items[i].mobile")
    ls_Note = loo_JResp.StringOf("items[i].note")
    li_Personal = loo_JResp.BoolOf("items[i].personal")
    ls_Phone_1 = loo_JResp.StringOf("items[i].phone_1")
    ls_Phone_2 = loo_JResp.StringOf("items[i].phone_2")
    ls_Salutation = loo_JResp.StringOf("items[i].salutation")
    ls_Suffix_1 = loo_JResp.StringOf("items[i].suffix_1")
    ls_Suffix_2 = loo_JResp.StringOf("items[i].suffix_2")
    ls_Title = loo_JResp.StringOf("items[i].title")
    ls_Zip_code = loo_JResp.StringOf("items[i].zip_code")
    ls_Created_at = loo_JResp.StringOf("items[i].created_at")
    ls_Updated_at = loo_JResp.StringOf("items[i].updated_at")
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -G -d "limit=%3Cinteger%3E"
	-d "page=%3Cinteger%3E"
	-H "Authorization: {{apiKey}}"
	-H "Accept: application/json"
https://api.easybill.de/rest/v1/customers/:customerId/contacts

Postman Collection Item JSON

{
  "name": "Fetch customer contact list",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/customers/:customerId/contacts?limit=<integer>&page=<integer>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "customers",
        ":customerId",
        "contacts"
      ],
      "query": [
        {
          "key": "limit",
          "value": "<integer>",
          "description": "Limited the result. Default is 100. Maximum can be 1000."
        },
        {
          "key": "page",
          "value": "<integer>",
          "description": "Set current Page. Default is 1."
        }
      ],
      "variable": [
        {
          "key": "customerId",
          "value": "<long>",
          "description": "(Required) ID of customer that needs to be fetched"
        }
      ]
    }
  },
  "response": [
    {
      "name": "Successful operation",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/customers/:customerId/contacts?limit=<integer>&page=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "customers",
            ":customerId",
            "contacts"
          ],
          "query": [
            {
              "key": "limit",
              "value": "<integer>",
              "description": "Limited the result. Default is 100. Maximum can be 1000."
            },
            {
              "key": "page",
              "value": "<integer>",
              "description": "Set current Page. Default is 1."
            }
          ],
          "variable": [
            {
              "key": "customerId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"page\": \"<integer>\",\n  \"pages\": \"<integer>\",\n  \"limit\": \"<integer>\",\n  \"total\": \"<integer>\",\n  \"items\": [\n    {\n      \"city\": \"<string>\",\n      \"street\": \"<string>\",\n      \"state\": \"<string>\",\n      \"company_name\": \"<string>\",\n      \"country\": \"<string>\",\n      \"department\": null,\n      \"fax\": null,\n      \"first_name\": null,\n      \"id\": \"<long>\",\n      \"last_name\": null,\n      \"login_id\": \"<long>\",\n      \"mobile\": null,\n      \"note\": null,\n      \"personal\": false,\n      \"phone_1\": null,\n      \"phone_2\": null,\n      \"salutation\": \"<integer>\",\n      \"suffix_1\": null,\n      \"suffix_2\": null,\n      \"title\": null,\n      \"zip_code\": null,\n      \"created_at\": \"<string>\",\n      \"updated_at\": \"<string>\"\n    },\n    {\n      \"city\": \"<string>\",\n      \"street\": \"<string>\",\n      \"state\": \"<string>\",\n      \"company_name\": \"<string>\",\n      \"country\": \"<string>\",\n      \"department\": null,\n      \"fax\": null,\n      \"first_name\": null,\n      \"id\": \"<long>\",\n      \"last_name\": null,\n      \"login_id\": \"<long>\",\n      \"mobile\": null,\n      \"note\": null,\n      \"personal\": false,\n      \"phone_1\": null,\n      \"phone_2\": null,\n      \"salutation\": \"<integer>\",\n      \"suffix_1\": null,\n      \"suffix_2\": null,\n      \"title\": null,\n      \"zip_code\": null,\n      \"created_at\": \"<string>\",\n      \"updated_at\": \"<string>\"\n    }\n  ]\n}"
    },
    {
      "name": "Too Many Requests",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/customers/:customerId/contacts?limit=<integer>&page=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "customers",
            ":customerId",
            "contacts"
          ],
          "query": [
            {
              "key": "limit",
              "value": "<integer>",
              "description": "Limited the result. Default is 100. Maximum can be 1000."
            },
            {
              "key": "page",
              "value": "<integer>",
              "description": "Set current Page. Default is 1."
            }
          ],
          "variable": [
            {
              "key": "customerId"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}