Chilkat Online Tools

Xojo / New FreshBooks / Get System

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>"
http.SetRequestHeader "Content-Type","application/json"

Dim sbResponseBody As New Chilkat.StringBuilder
success = http.QuickGetSb("https://api.freshbooks.com/accounting/account/{{accountId}}/systems/systems/{{businessId}}",sbResponseBody)
If (success = False) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

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

System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())

Dim respStatusCode As Int32
respStatusCode = http.LastStatus
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
    System.DebugLog("Response Header:")
    System.DebugLog(http.LastHeader)
    System.DebugLog("Failed.")
    Return
End If

// 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

Dim Accountid As String
Accountid = jResp.StringOf("response.result.system.accountid")
Dim Active As Boolean
Active = jResp.BoolOf("response.result.system.active")
Dim Auto_bill As Int32
Auto_bill = jResp.IntOf("response.result.system.auto_bill")
Dim Billing_status As String
Billing_status = jResp.StringOf("response.result.system.billing_status")
Dim Bus_phone As String
Bus_phone = jResp.StringOf("response.result.system.bus_phone")
Dim Business_type As String
Business_type = jResp.StringOf("response.result.system.business_type")
Dim Business_uuid As String
Business_uuid = jResp.StringOf("response.result.system.business_uuid")
Dim City As String
City = jResp.StringOf("response.result.system.city")
Dim Code As String
Code = jResp.StringOf("response.result.system.code")
Dim Country As String
Country = jResp.StringOf("response.result.system.country")
Dim Currency_code As String
Currency_code = jResp.StringOf("response.result.system.currency_code")
Dim Date As String
Date = jResp.StringOf("response.result.system.date")
Dim Discountid As String
Discountid = jResp.StringOf("response.result.system.discountid")
Dim Dst As Boolean
Dst = jResp.BoolOf("response.result.system.dst")
Dim Duration As Int32
Duration = jResp.IntOf("response.result.system.duration")
Dim v_Email As String
v_Email = jResp.StringOf("response.result.system.email")
Dim Fax As String
Fax = jResp.StringOf("response.result.system.fax")
Dim Amount As String
Amount = jResp.StringOf("response.result.system.gst_amount.amount")
Dim Gst_amountCode As String
Gst_amountCode = jResp.StringOf("response.result.system.gst_amount.code")
Dim Heard_about_us_via As String
Heard_about_us_via = jResp.StringOf("response.result.system.heard_about_us_via")
Dim Id As Int32
Id = jResp.IntOf("response.result.system.id")
Dim Info_email As String
Info_email = jResp.StringOf("response.result.system.info_email")
Dim Ip As String
Ip = jResp.StringOf("response.result.system.ip")
Dim Landing_url As String
Landing_url = jResp.StringOf("response.result.system.landing_url")
Dim Masterlock_billing As Boolean
Masterlock_billing = jResp.BoolOf("response.result.system.masterlock_billing")
Dim Migrated_to_smux_at As String
Migrated_to_smux_at = jResp.StringOf("response.result.system.migrated_to_smux_at")
Dim Mob_phone As String
Mob_phone = jResp.StringOf("response.result.system.mob_phone")
Dim Modern_system As Boolean
Modern_system = jResp.BoolOf("response.result.system.modern_system")
Dim Name As String
Name = jResp.StringOf("response.result.system.name")
Dim Num_clients As String
Num_clients = jResp.StringOf("response.result.system.num_clients")
Dim Num_staff As String
Num_staff = jResp.StringOf("response.result.system.num_staff")
Dim Payment_amountAmount As String
Payment_amountAmount = jResp.StringOf("response.result.system.payment_amount.amount")
Dim Payment_amountCode As String
Payment_amountCode = jResp.StringOf("response.result.system.payment_amount.code")
Dim Payment_frequency As Int32
Payment_frequency = jResp.IntOf("response.result.system.payment_frequency")
Dim Province As String
Province = jResp.StringOf("response.result.system.province")
Dim Referralid As String
Referralid = jResp.StringOf("response.result.system.referralid")
Dim Referring_url As String
Referring_url = jResp.StringOf("response.result.system.referring_url")
Dim Salutation As String
Salutation = jResp.StringOf("response.result.system.salutation")
Dim Size_limit As String
Size_limit = jResp.StringOf("response.result.system.size_limit")
Dim Split_token As String
Split_token = jResp.StringOf("response.result.system.split_token")
Dim Street As String
Street = jResp.StringOf("response.result.system.street")
Dim Street2 As String
Street2 = jResp.StringOf("response.result.system.street2")
Dim Systemid As Int32
Systemid = jResp.IntOf("response.result.system.systemid")
Dim Test_system As Boolean
Test_system = jResp.BoolOf("response.result.system.test_system")
Dim Timezone As String
Timezone = jResp.StringOf("response.result.system.timezone")
Dim Timezoneid As Int32
Timezoneid = jResp.IntOf("response.result.system.timezoneid")
Dim Vat_name As String
Vat_name = jResp.StringOf("response.result.system.vat_name")
Dim Vat_number As String
Vat_number = jResp.StringOf("response.result.system.vat_number")

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