Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *Accountid;
BOOL Active;
int Auto_bill;
const wchar_t *Billing_status;
const wchar_t *Bus_phone;
const wchar_t *Business_type;
const wchar_t *Business_uuid;
const wchar_t *City;
const wchar_t *Code;
const wchar_t *Country;
const wchar_t *Currency_code;
const wchar_t *Date;
const wchar_t *Discountid;
BOOL Dst;
int Duration;
const wchar_t *v_Email;
const wchar_t *Fax;
const wchar_t *Amount;
const wchar_t *Gst_amountCode;
const wchar_t *Heard_about_us_via;
int Id;
const wchar_t *Info_email;
const wchar_t *Ip;
const wchar_t *Landing_url;
BOOL Masterlock_billing;
const wchar_t *Migrated_to_smux_at;
const wchar_t *Mob_phone;
BOOL Modern_system;
const wchar_t *Name;
const wchar_t *Num_clients;
const wchar_t *Num_staff;
const wchar_t *Payment_amountAmount;
const wchar_t *Payment_amountCode;
int Payment_frequency;
const wchar_t *Province;
const wchar_t *Referralid;
const wchar_t *Referring_url;
const wchar_t *Salutation;
const wchar_t *Size_limit;
const wchar_t *Split_token;
const wchar_t *Street;
const wchar_t *Street2;
int Systemid;
BOOL Test_system;
const wchar_t *Timezone;
int Timezoneid;
const wchar_t *Vat_name;
const wchar_t *Vat_number;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://api.freshbooks.com/accounting/account/{{accountId}}/systems/systems/{{businessId}}",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpW_lastHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "response": {
// "result": {
// "system": {
// "accountid": "wkMd2g",
// "active": true,
// "auto_bill": 5,
// "billing_status": "uptodate",
// "bus_phone": "",
// "business_type": null,
// "business_uuid": null,
// "city": "",
// "code": "",
// "country": "Canada",
// "currency_code": "USD",
// "date": "2019-04-18 09:14:53",
// "discountid": null,
// "dst": true,
// "duration": 12,
// "email": "api.freshbooks@gmail.com",
// "fax": "",
// "gst_amount": {
// "amount": "0.00",
// "code": "USD"
// },
// "heard_about_us_via": null,
// "id": 4236410,
// "info_email": "api.freshbooks@gmail.com",
// "ip": "62.205.194.4",
// "landing_url": null,
// "masterlock_billing": true,
// "migrated_to_smux_at": null,
// "mob_phone": "",
// "modern_system": true,
// "name": "Postman Sandbox",
// "num_clients": null,
// "num_staff": null,
// "payment_amount": {
// "amount": "0.00",
// "code": "USD"
// },
// "payment_frequency": 1,
// "province": "",
// "referralid": "multibiz",
// "referring_url": null,
// "salutation": null,
// "size_limit": null,
// "split_token": null,
// "street": "",
// "street2": null,
// "systemid": 4236410,
// "test_system": false,
// "timezone": "UTC",
// "timezoneid": 14,
// "vat_name": null,
// "vat_number": null
// }
// }
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
Accountid = CkJsonObjectW_stringOf(jResp,L"response.result.system.accountid");
Active = CkJsonObjectW_BoolOf(jResp,L"response.result.system.active");
Auto_bill = CkJsonObjectW_IntOf(jResp,L"response.result.system.auto_bill");
Billing_status = CkJsonObjectW_stringOf(jResp,L"response.result.system.billing_status");
Bus_phone = CkJsonObjectW_stringOf(jResp,L"response.result.system.bus_phone");
Business_type = CkJsonObjectW_stringOf(jResp,L"response.result.system.business_type");
Business_uuid = CkJsonObjectW_stringOf(jResp,L"response.result.system.business_uuid");
City = CkJsonObjectW_stringOf(jResp,L"response.result.system.city");
Code = CkJsonObjectW_stringOf(jResp,L"response.result.system.code");
Country = CkJsonObjectW_stringOf(jResp,L"response.result.system.country");
Currency_code = CkJsonObjectW_stringOf(jResp,L"response.result.system.currency_code");
Date = CkJsonObjectW_stringOf(jResp,L"response.result.system.date");
Discountid = CkJsonObjectW_stringOf(jResp,L"response.result.system.discountid");
Dst = CkJsonObjectW_BoolOf(jResp,L"response.result.system.dst");
Duration = CkJsonObjectW_IntOf(jResp,L"response.result.system.duration");
v_Email = CkJsonObjectW_stringOf(jResp,L"response.result.system.email");
Fax = CkJsonObjectW_stringOf(jResp,L"response.result.system.fax");
Amount = CkJsonObjectW_stringOf(jResp,L"response.result.system.gst_amount.amount");
Gst_amountCode = CkJsonObjectW_stringOf(jResp,L"response.result.system.gst_amount.code");
Heard_about_us_via = CkJsonObjectW_stringOf(jResp,L"response.result.system.heard_about_us_via");
Id = CkJsonObjectW_IntOf(jResp,L"response.result.system.id");
Info_email = CkJsonObjectW_stringOf(jResp,L"response.result.system.info_email");
Ip = CkJsonObjectW_stringOf(jResp,L"response.result.system.ip");
Landing_url = CkJsonObjectW_stringOf(jResp,L"response.result.system.landing_url");
Masterlock_billing = CkJsonObjectW_BoolOf(jResp,L"response.result.system.masterlock_billing");
Migrated_to_smux_at = CkJsonObjectW_stringOf(jResp,L"response.result.system.migrated_to_smux_at");
Mob_phone = CkJsonObjectW_stringOf(jResp,L"response.result.system.mob_phone");
Modern_system = CkJsonObjectW_BoolOf(jResp,L"response.result.system.modern_system");
Name = CkJsonObjectW_stringOf(jResp,L"response.result.system.name");
Num_clients = CkJsonObjectW_stringOf(jResp,L"response.result.system.num_clients");
Num_staff = CkJsonObjectW_stringOf(jResp,L"response.result.system.num_staff");
Payment_amountAmount = CkJsonObjectW_stringOf(jResp,L"response.result.system.payment_amount.amount");
Payment_amountCode = CkJsonObjectW_stringOf(jResp,L"response.result.system.payment_amount.code");
Payment_frequency = CkJsonObjectW_IntOf(jResp,L"response.result.system.payment_frequency");
Province = CkJsonObjectW_stringOf(jResp,L"response.result.system.province");
Referralid = CkJsonObjectW_stringOf(jResp,L"response.result.system.referralid");
Referring_url = CkJsonObjectW_stringOf(jResp,L"response.result.system.referring_url");
Salutation = CkJsonObjectW_stringOf(jResp,L"response.result.system.salutation");
Size_limit = CkJsonObjectW_stringOf(jResp,L"response.result.system.size_limit");
Split_token = CkJsonObjectW_stringOf(jResp,L"response.result.system.split_token");
Street = CkJsonObjectW_stringOf(jResp,L"response.result.system.street");
Street2 = CkJsonObjectW_stringOf(jResp,L"response.result.system.street2");
Systemid = CkJsonObjectW_IntOf(jResp,L"response.result.system.systemid");
Test_system = CkJsonObjectW_BoolOf(jResp,L"response.result.system.test_system");
Timezone = CkJsonObjectW_stringOf(jResp,L"response.result.system.timezone");
Timezoneid = CkJsonObjectW_IntOf(jResp,L"response.result.system.timezoneid");
Vat_name = CkJsonObjectW_stringOf(jResp,L"response.result.system.vat_name");
Vat_number = CkJsonObjectW_stringOf(jResp,L"response.result.system.vat_number");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
https://api.freshbooks.com/accounting/account/{{accountId}}/systems/systems/{{businessId}}
Postman Collection Item JSON
{
"name": "Get System ",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/systems/systems/{{businessId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"{{accountId}}",
"systems",
"systems",
"{{businessId}}"
]
},
"description": "The value of `<id>` here is only meaningful if a user has access to multiple systems. See the Identity Model for more information."
},
"response": [
{
"name": "Get System ",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/systems/systems/{{businessId}}",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"accounting",
"account",
"{{accountId}}",
"systems",
"systems",
"{{businessId}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABVlVSAwEOVlcTGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4DFVdfRgFPCkNFR0gXSEVHBwsQWEMbSxZdVRYeA0kJTwFZC1VXAgRZXlANAgRQUVYEHRpXSBNUVlBfBwAFAQlUDw8GVwFUG01XAF8RAWs="
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Expires",
"value": "Tue, 24 Apr 2018 18:38:32 GMT"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Age",
"value": "0"
},
{
"key": "Age",
"value": "0"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Date",
"value": "Wed, 24 Apr 2019 18:38:32 GMT"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Served-By",
"value": "cache-mdw17369-MDW"
},
{
"key": "X-Cache",
"value": "MISS"
},
{
"key": "X-Cache-Hits",
"value": "0"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Country",
"value": "CA"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains; preload"
}
],
"cookie": [
],
"body": "{\n \"response\": {\n \"result\": {\n \"system\": {\n \"accountid\": \"wkMd2g\",\n \"active\": true,\n \"auto_bill\": 5,\n \"billing_status\": \"uptodate\",\n \"bus_phone\": \"\",\n \"business_type\": null,\n \"business_uuid\": null,\n \"city\": \"\",\n \"code\": \"\",\n \"country\": \"Canada\",\n \"currency_code\": \"USD\",\n \"date\": \"2019-04-18 09:14:53\",\n \"discountid\": null,\n \"dst\": true,\n \"duration\": 12,\n \"email\": \"api.freshbooks@gmail.com\",\n \"fax\": \"\",\n \"gst_amount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"heard_about_us_via\": null,\n \"id\": 4236410,\n \"info_email\": \"api.freshbooks@gmail.com\",\n \"ip\": \"62.205.194.4\",\n \"landing_url\": null,\n \"masterlock_billing\": true,\n \"migrated_to_smux_at\": null,\n \"mob_phone\": \"\",\n \"modern_system\": true,\n \"name\": \"Postman Sandbox\",\n \"num_clients\": null,\n \"num_staff\": null,\n \"payment_amount\": {\n \"amount\": \"0.00\",\n \"code\": \"USD\"\n },\n \"payment_frequency\": 1,\n \"province\": \"\",\n \"referralid\": \"multibiz\",\n \"referring_url\": null,\n \"salutation\": null,\n \"size_limit\": null,\n \"split_token\": null,\n \"street\": \"\",\n \"street2\": null,\n \"systemid\": 4236410,\n \"test_system\": false,\n \"timezone\": \"UTC\",\n \"timezoneid\": 14,\n \"vat_name\": null,\n \"vat_number\": null\n }\n }\n }\n}"
}
]
}