Chilkat Online Tools

PowerBuilder / New FreshBooks / Get System

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Accountid
integer li_Active
integer li_Auto_bill
string ls_Billing_status
string ls_Bus_phone
string ls_Business_type
string ls_Business_uuid
string ls_City
string ls_Code
string ls_Country
string ls_Currency_code
string ls_Date
string ls_Discountid
integer li_Dst
integer li_Duration
string ls_V_Email
string ls_Fax
string ls_Amount
string ls_Gst_amountCode
string ls_Heard_about_us_via
integer li_Id
string ls_Info_email
string ls_Ip
string ls_Landing_url
integer li_Masterlock_billing
string ls_Migrated_to_smux_at
string ls_Mob_phone
integer li_Modern_system
string ls_Name
string ls_Num_clients
string ls_Num_staff
string ls_Payment_amountAmount
string ls_Payment_amountCode
integer li_Payment_frequency
string ls_Province
string ls_Referralid
string ls_Referring_url
string ls_Salutation
string ls_Size_limit
string ls_Split_token
string ls_Street
string ls_Street2
integer li_Systemid
integer li_Test_system
string ls_Timezone
integer li_Timezoneid
string ls_Vat_name
string ls_Vat_number

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

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"
loo_Http.SetRequestHeader("Content-Type","application/json")

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

li_Success = loo_Http.QuickGetSb("https://api.freshbooks.com/accounting/account/{{accountId}}/systems/systems/{{businessId}}",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
// 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_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)

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

ls_Accountid = loo_JResp.StringOf("response.result.system.accountid")
li_Active = loo_JResp.BoolOf("response.result.system.active")
li_Auto_bill = loo_JResp.IntOf("response.result.system.auto_bill")
ls_Billing_status = loo_JResp.StringOf("response.result.system.billing_status")
ls_Bus_phone = loo_JResp.StringOf("response.result.system.bus_phone")
ls_Business_type = loo_JResp.StringOf("response.result.system.business_type")
ls_Business_uuid = loo_JResp.StringOf("response.result.system.business_uuid")
ls_City = loo_JResp.StringOf("response.result.system.city")
ls_Code = loo_JResp.StringOf("response.result.system.code")
ls_Country = loo_JResp.StringOf("response.result.system.country")
ls_Currency_code = loo_JResp.StringOf("response.result.system.currency_code")
ls_Date = loo_JResp.StringOf("response.result.system.date")
ls_Discountid = loo_JResp.StringOf("response.result.system.discountid")
li_Dst = loo_JResp.BoolOf("response.result.system.dst")
li_Duration = loo_JResp.IntOf("response.result.system.duration")
ls_V_Email = loo_JResp.StringOf("response.result.system.email")
ls_Fax = loo_JResp.StringOf("response.result.system.fax")
ls_Amount = loo_JResp.StringOf("response.result.system.gst_amount.amount")
ls_Gst_amountCode = loo_JResp.StringOf("response.result.system.gst_amount.code")
ls_Heard_about_us_via = loo_JResp.StringOf("response.result.system.heard_about_us_via")
li_Id = loo_JResp.IntOf("response.result.system.id")
ls_Info_email = loo_JResp.StringOf("response.result.system.info_email")
ls_Ip = loo_JResp.StringOf("response.result.system.ip")
ls_Landing_url = loo_JResp.StringOf("response.result.system.landing_url")
li_Masterlock_billing = loo_JResp.BoolOf("response.result.system.masterlock_billing")
ls_Migrated_to_smux_at = loo_JResp.StringOf("response.result.system.migrated_to_smux_at")
ls_Mob_phone = loo_JResp.StringOf("response.result.system.mob_phone")
li_Modern_system = loo_JResp.BoolOf("response.result.system.modern_system")
ls_Name = loo_JResp.StringOf("response.result.system.name")
ls_Num_clients = loo_JResp.StringOf("response.result.system.num_clients")
ls_Num_staff = loo_JResp.StringOf("response.result.system.num_staff")
ls_Payment_amountAmount = loo_JResp.StringOf("response.result.system.payment_amount.amount")
ls_Payment_amountCode = loo_JResp.StringOf("response.result.system.payment_amount.code")
li_Payment_frequency = loo_JResp.IntOf("response.result.system.payment_frequency")
ls_Province = loo_JResp.StringOf("response.result.system.province")
ls_Referralid = loo_JResp.StringOf("response.result.system.referralid")
ls_Referring_url = loo_JResp.StringOf("response.result.system.referring_url")
ls_Salutation = loo_JResp.StringOf("response.result.system.salutation")
ls_Size_limit = loo_JResp.StringOf("response.result.system.size_limit")
ls_Split_token = loo_JResp.StringOf("response.result.system.split_token")
ls_Street = loo_JResp.StringOf("response.result.system.street")
ls_Street2 = loo_JResp.StringOf("response.result.system.street2")
li_Systemid = loo_JResp.IntOf("response.result.system.systemid")
li_Test_system = loo_JResp.BoolOf("response.result.system.test_system")
ls_Timezone = loo_JResp.StringOf("response.result.system.timezone")
li_Timezoneid = loo_JResp.IntOf("response.result.system.timezoneid")
ls_Vat_name = loo_JResp.StringOf("response.result.system.vat_name")
ls_Vat_number = loo_JResp.StringOf("response.result.system.vat_number")


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_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}"
    }
  ]
}