Chilkat Online Tools

PureBasic / New FreshBooks / List Expenses

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    queryParams.i = CkJsonObject::ckCreate()
    If queryParams.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(queryParams,"include[]","attachment")
    CkJsonObject::ckUpdateString(queryParams,"include[]","category")
    CkJsonObject::ckUpdateString(queryParams,"include[]","expense_profile")
    CkJsonObject::ckUpdateString(queryParams,"include[]","project")
    CkJsonObject::ckUpdateString(queryParams,"include[]","account")

    ; Adds the "Authorization: Bearer <access_token>" header.
    CkHttp::setCkAuthToken(http, "<access_token>")
    CkHttp::ckSetRequestHeader(http,"Content-Type","application/json")

    resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://api.freshbooks.com/accounting/account/{{accountId}}/expenses/expenses",queryParams)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        ProcedureReturn
    EndIf

    sbResponseBody.i = CkStringBuilder::ckCreate()
    If sbResponseBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkHttpResponse::ckGetBodySb(resp,sbResponseBody)

    jResp.i = CkJsonObject::ckCreate()
    If jResp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoadSb(jResp,sbResponseBody)
    CkJsonObject::setCkEmitCompact(jResp, 0)

    Debug "Response Body:"
    Debug CkJsonObject::ckEmit(jResp)

    respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
    Debug "Response Status Code = " + Str(respStatusCode)
    If respStatusCode >= 400
        Debug "Response Header:"
        Debug CkHttpResponse::ckHeader(resp)
        Debug "Failed."
        CkHttpResponse::ckDispose(resp)

        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        CkStringBuilder::ckDispose(sbResponseBody)
        CkJsonObject::ckDispose(jResp)
        ProcedureReturn
    EndIf

    CkHttpResponse::ckDispose(resp)

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

    ; {
    ;   "response": {
    ;     "result": {
    ;       "expenses": [
    ;         {
    ;           "account_name": "",
    ;           "accountid": null,
    ;           "accounting_systemid": "wkMd2g",
    ;           "amount": {
    ;             "amount": "79.73",
    ;             "code": "USD"
    ;           },
    ;           "attachment": {
    ;             "attachmentid": 8668,
    ;             "id": 8668,
    ;             "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6IlNjcmVlbiBTaG90IDIwMTktMDQtMjQgYXQgOS4zOS4xOSBBTS5wbmciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtMGU2ZDMwOWQ1ZTI5MzA3NmNhMGIyNDdkODFlOGJlNWE4NDZlZWE0YSIsImxlbmd0aCI6MTkxNDcyLCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTBlNmQzMDlkNWUyOTMwNzZjYTBiMjQ3ZDgxZThiZTVhODQ2ZWVhNGEifQ.SOoW3_nTUrxjYO76g1UXHPIrO_aLbTpXCHEa-ZcnejA",
    ;             "media_type": "image/png"
    ;           },
    ;           "background_jobid": null,
    ;           "bank_name": "",
    ;           "category": {
    ;             "category": "Gas",
    ;             "categoryid": 2003174,
    ;             "created_at": "2019-04-18 09:14:52",
    ;             "id": 2003174,
    ;             "is_cogs": false,
    ;             "is_editable": false,
    ;             "parentid": 2003170,
    ;             "updated_at": "2019-04-18 09:14:52",
    ;             "vis_state": 0
    ;           },
    ;           "categoryid": 2003174,
    ;           "clientid": 0,
    ;           "compounded_tax": false,
    ;           "date": "2019-04-24",
    ;           "expense_profile": null,
    ;           "expenseid": 1825568,
    ;           "ext_invoiceid": 0,
    ;           "ext_systemid": 0,
    ;           "from_bulk_import": false,
    ;           "has_receipt": true,
    ;           "id": 1825568,
    ;           "include_receipt": false,
    ;           "invoiceid": null,
    ;           "is_cogs": false,
    ;           "isduplicate": true,
    ;           "markup_percent": "0",
    ;           "notes": "Purchased Gasoline for deliveries",
    ;           "profileid": null,
    ;           "project": null,
    ;           "projectid": 0,
    ;           "staffid": 1,
    ;           "status": 0,
    ;           "taxAmount1": {
    ;             "amount": "9.17",
    ;             "code": "USD"
    ;           },
    ;           "taxAmount2": null,
    ;           "taxName1": "other tax",
    ;           "taxName2": null,
    ;           "taxPercent1": "13",
    ;           "taxPercent2": null,
    ;           "transactionid": null,
    ;           "updated": "2019-04-24 11:33:35",
    ;           "vendor": "Shell Gas Station",
    ;           "vis_state": 0
    ;         },
    ;         {
    ;           "account_name": "",
    ;           "accountid": null,
    ;           "accounting_systemid": "wkMd2g",
    ;           "amount": {
    ;             "amount": "79.73",
    ;             "code": "USD"
    ;           },
    ;           "attachment": {
    ;             "attachmentid": 8670,
    ;             "id": 8670,
    ;             "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6IlNjcmVlbiBTaG90IDIwMTktMDQtMjQgYXQgOS4zOS4xOSBBTS5wbmciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtMGU2ZDMwOWQ1ZTI5MzA3NmNhMGIyNDdkODFlOGJlNWE4NDZlZWE0YSIsImxlbmd0aCI6MTkxNDcyLCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTBlNmQzMDlkNWUyOTMwNzZjYTBiMjQ3ZDgxZThiZTVhODQ2ZWVhNGEifQ.SOoW3_nTUrxjYO76g1UXHPIrO_aLbTpXCHEa-ZcnejA",
    ;             "media_type": "image/png"
    ;           },
    ;           "background_jobid": null,
    ;           "bank_name": "",
    ;           "category": {
    ;             "category": "Gas",
    ;             "categoryid": 2003174,
    ;             "created_at": "2019-04-18 09:14:52",
    ;             "id": 2003174,
    ;             "is_cogs": false,
    ;             "is_editable": false,
    ;             "parentid": 2003170,
    ;             "updated_at": "2019-04-18 09:14:52",
    ;             "vis_state": 0
    ;           },
    ;           "categoryid": 2003174,
    ;           "clientid": 0,
    ;           "compounded_tax": false,
    ;           "date": "2019-04-24",
    ;           "expense_profile": null,
    ;           "expenseid": 1825574,
    ;           "ext_invoiceid": 0,
    ;           "ext_systemid": 0,
    ;           "from_bulk_import": false,
    ;           "has_receipt": true,
    ;           "id": 1825574,
    ;           "include_receipt": false,
    ;           "invoiceid": null,
    ;           "is_cogs": false,
    ;           "isduplicate": true,
    ;           "markup_percent": "0",
    ;           "notes": "Purchased Gasoline for deliveries",
    ;           "profileid": null,
    ;           "project": null,
    ;           "projectid": 0,
    ;           "staffid": 1,
    ;           "status": 0,
    ;           "taxAmount1": {
    ;             "amount": "9.17",
    ;             "code": "USD"
    ;           },
    ;           "taxAmount2": null,
    ;           "taxName1": "other tax",
    ;           "taxName2": null,
    ;           "taxPercent1": "13",
    ;           "taxPercent2": null,
    ;           "transactionid": null,
    ;           "updated": "2019-04-24 11:38:00",
    ;           "vendor": "Shell Gas Station",
    ;           "vis_state": 2
    ;         },
    ;         {
    ;           "account_name": "",
    ;           "accountid": null,
    ;           "accounting_systemid": "wkMd2g",
    ;           "amount": {
    ;             "amount": "79.73",
    ;             "code": "USD"
    ;           },
    ;           "attachment": {
    ;             "attachmentid": 12138,
    ;             "id": 12138,
    ;             "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6IlNjcmVlbiBTaG90IDIwMTktMDQtMjQgYXQgOS4zOS4xOSBBTS5wbmciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtMGU2ZDMwOWQ1ZTI5MzA3NmNhMGIyNDdkODFlOGJlNWE4NDZlZWE0YSIsImxlbmd0aCI6MTkxNDcyLCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTBlNmQzMDlkNWUyOTMwNzZjYTBiMjQ3ZDgxZThiZTVhODQ2ZWVhNGEifQ.SOoW3_nTUrxjYO76g1UXHPIrO_aLbTpXCHEa-ZcnejA",
    ;             "media_type": "image/png"
    ;           },
    ;           "background_jobid": null,
    ;           "bank_name": "",
    ;           "category": {
    ;             "category": "Gas",
    ;             "categoryid": 2003174,
    ;             "created_at": "2019-04-18 09:14:52",
    ;             "id": 2003174,
    ;             "is_cogs": false,
    ;             "is_editable": false,
    ;             "parentid": 2003170,
    ;             "updated_at": "2019-04-18 09:14:52",
    ;             "vis_state": 0
    ;           },
    ;           "categoryid": 2003174,
    ;           "clientid": 0,
    ;           "compounded_tax": false,
    ;           "date": "2019-04-24",
    ;           "expense_profile": null,
    ;           "expenseid": 2721846,
    ;           "ext_invoiceid": 0,
    ;           "ext_systemid": 0,
    ;           "from_bulk_import": false,
    ;           "has_receipt": true,
    ;           "id": 2721846,
    ;           "include_receipt": false,
    ;           "invoiceid": null,
    ;           "is_cogs": false,
    ;           "isduplicate": true,
    ;           "markup_percent": "0",
    ;           "notes": "Purchased Gasoline for deliveries",
    ;           "profileid": null,
    ;           "project": null,
    ;           "projectid": 0,
    ;           "staffid": 1,
    ;           "status": 0,
    ;           "taxAmount1": {
    ;             "amount": "9.17",
    ;             "code": "USD"
    ;           },
    ;           "taxAmount2": null,
    ;           "taxName1": "other tax",
    ;           "taxName2": null,
    ;           "taxPercent1": "13",
    ;           "taxPercent2": null,
    ;           "transactionid": null,
    ;           "updated": "2019-04-30 16:48:22",
    ;           "vendor": "Shell Gas Station",
    ;           "vis_state": 0
    ;         },
    ;         {
    ;           "account_name": "",
    ;           "accountid": null,
    ;           "accounting_systemid": "wkMd2g",
    ;           "amount": {
    ;             "amount": "7000.99",
    ;             "code": "USD"
    ;           },
    ;           "attachment": {
    ;             "attachmentid": 6122,
    ;             "id": 6122,
    ;             "jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6IlNjcmVlbiBTaG90IDIwMTktMDQtMTYgYXQgMTEuMzcuMjEgQU0ucG5nIiwiYnVja2V0IjoidXBsb2FkcyIsImZpbGVuYW1lIjoidXBsb2FkLTJjMDY0NDEwZDQwYjE1NTRkZTAyM2Q1MjNlNmJjOTA3NDMyYmIwMGMiLCJsZW5ndGgiOjE0NTk2MCwia2V5IjoiJ2RvY3MtJy00MjM2NDEwL3VwbG9hZC0yYzA2NDQxMGQ0MGIxNTU0ZGUwMjNkNTIzZTZiYzkwNzQzMmJiMDBjIn0.MogtZWv_c3mllnjMzX5DEP2J5PBsEa1ZfHwdXgywRoM",
    ;             "media_type": "image/png"
    ;           },
    ;           "background_jobid": null,
    ;           "bank_name": "",
    ;           "category": {
    ;             "category": "Computer Parts",
    ;             "categoryid": 2005674,
    ;             "created_at": "2019-04-18 09:40:57",
    ;             "id": 2005674,
    ;             "is_cogs": false,
    ;             "is_editable": true,
    ;             "parentid": 2003142,
    ;             "updated_at": "2019-04-18 09:40:57",
    ;             "vis_state": 0
    ;           },
    ;           "categoryid": 2005674,
    ;           "clientid": 0,
    ;           "compounded_tax": false,
    ;           "date": "2019-04-18",
    ;           "expense_profile": null,
    ;           "expenseid": 1034972,
    ;           "ext_invoiceid": 0,
    ;           "ext_systemid": 0,
    ;           "from_bulk_import": false,
    ;           "has_receipt": true,
    ;           "id": 1034972,
    ;           "include_receipt": false,
    ;           "invoiceid": null,
    ;           "is_cogs": false,
    ;           "isduplicate": false,
    ;           "markup_percent": "0",
    ;           "notes": "Need the parts to make the computer hardware",
    ;           "profileid": null,
    ;           "project": null,
    ;           "projectid": 0,
    ;           "staffid": 1,
    ;           "status": 0,
    ;           "taxAmount1": {
    ;             "amount": "805.42",
    ;             "code": "USD"
    ;           },
    ;           "taxAmount2": null,
    ;           "taxName1": "HST",
    ;           "taxName2": null,
    ;           "taxPercent1": "13",
    ;           "taxPercent2": null,
    ;           "transactionid": null,
    ;           "updated": "2019-04-18 09:41:44",
    ;           "vendor": "Computer Parts People",
    ;           "vis_state": 0
    ;         },
    ;         {
    ;           "account_name": "",
    ;           "accountid": null,
    ;           "accounting_systemid": "wkMd2g",
    ;           "amount": {
    ;             "amount": "39.991",
    ;             "code": "USD"
    ;           },
    ;           "attachment": null,
    ;           "background_jobid": null,
    ;           "bank_name": "",
    ;           "category": {
    ;             "category": "Equipment",
    ;             "categoryid": 2003232,
    ;             "created_at": "2019-04-18 09:14:52",
    ;             "id": 2003232,
    ;             "is_cogs": false,
    ;             "is_editable": false,
    ;             "parentid": 2003226,
    ;             "updated_at": "2019-04-18 09:14:52",
    ;             "vis_state": 0
    ;           },
    ;           "categoryid": 2003232,
    ;           "clientid": 0,
    ;           "compounded_tax": false,
    ;           "date": "2018-06-20",
    ;           "expense_profile": null,
    ;           "expenseid": 1553548,
    ;           "ext_invoiceid": 0,
    ;           "ext_systemid": 0,
    ;           "from_bulk_import": false,
    ;           "has_receipt": false,
    ;           "id": 1553548,
    ;           "include_receipt": false,
    ;           "invoiceid": null,
    ;           "is_cogs": false,
    ;           "isduplicate": false,
    ;           "markup_percent": "0",
    ;           "notes": "",
    ;           "profileid": null,
    ;           "project": null,
    ;           "projectid": 0,
    ;           "staffid": 31004,
    ;           "status": 0,
    ;           "taxAmount1": null,
    ;           "taxAmount2": null,
    ;           "taxName1": null,
    ;           "taxName2": null,
    ;           "taxPercent1": null,
    ;           "taxPercent2": null,
    ;           "transactionid": null,
    ;           "updated": "2019-04-24 11:39:15",
    ;           "vendor": null,
    ;           "vis_state": 0
    ;         }
    ;       ],
    ;       "page": 1,
    ;       "pages": 1,
    ;       "per_page": 15,
    ;       "total": 5
    ;     }
    ;   }
    ; }

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

    account_name.s
    accountid.s
    accounting_systemid.s
    Amount.s
    Code.s
    Attachmentid.i
    Id.i
    v_Jwt.s
    Media_type.s
    background_jobid.s
    bank_name.s
    Category.s
    Categoryid.i
    Created_at.s
    categoryId.i
    Is_cogs.i
    Is_editable.i
    Parentid.i
    Updated_at.s
    Vis_state.i
    categoryid.i
    clientid.i
    compounded_tax.i
    date.s
    expense_profile.s
    expenseid.i
    ext_invoiceid.i
    ext_systemid.i
    from_bulk_import.i
    has_receipt.i
    id.i
    include_receipt.i
    invoiceid.s
    is_cogs.i
    isduplicate.i
    markup_percent.s
    notes.s
    profileid.s
    project.s
    projectid.i
    staffid.i
    status.i
    taxAmount1Amount.s
    taxAmount1Code.s
    taxAmount2.s
    taxName1.s
    taxName2.s
    taxPercent1.s
    taxPercent2.s
    transactionid.s
    updated.s
    vendor.s
    vis_state.i
    attachment.s
    taxAmount1.s

    Page.i = CkJsonObject::ckIntOf(jResp,"response.result.page")
    Pages.i = CkJsonObject::ckIntOf(jResp,"response.result.pages")
    Per_page.i = CkJsonObject::ckIntOf(jResp,"response.result.per_page")
    Total.i = CkJsonObject::ckIntOf(jResp,"response.result.total")
    i.i = 0
    count_i.i = CkJsonObject::ckSizeOfArray(jResp,"response.result.expenses")
    While i < count_i
        CkJsonObject::setCkI(jResp, i)
        account_name = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].account_name")
        accountid = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].accountid")
        accounting_systemid = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].accounting_systemid")
        Amount = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].amount.amount")
        Code = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].amount.code")
        Attachmentid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].attachment.attachmentid")
        Id = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].attachment.id")
        v_Jwt = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].attachment.jwt")
        Media_type = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].attachment.media_type")
        background_jobid = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].background_jobid")
        bank_name = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].bank_name")
        Category = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].category.category")
        Categoryid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].category.categoryid")
        Created_at = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].category.created_at")
        categoryId = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].category.id")
        Is_cogs = CkJsonObject::ckBoolOf(jResp,"response.result.expenses[i].category.is_cogs")
        Is_editable = CkJsonObject::ckBoolOf(jResp,"response.result.expenses[i].category.is_editable")
        Parentid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].category.parentid")
        Updated_at = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].category.updated_at")
        Vis_state = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].category.vis_state")
        categoryid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].categoryid")
        clientid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].clientid")
        compounded_tax = CkJsonObject::ckBoolOf(jResp,"response.result.expenses[i].compounded_tax")
        date = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].date")
        expense_profile = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].expense_profile")
        expenseid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].expenseid")
        ext_invoiceid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].ext_invoiceid")
        ext_systemid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].ext_systemid")
        from_bulk_import = CkJsonObject::ckBoolOf(jResp,"response.result.expenses[i].from_bulk_import")
        has_receipt = CkJsonObject::ckBoolOf(jResp,"response.result.expenses[i].has_receipt")
        id = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].id")
        include_receipt = CkJsonObject::ckBoolOf(jResp,"response.result.expenses[i].include_receipt")
        invoiceid = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].invoiceid")
        is_cogs = CkJsonObject::ckBoolOf(jResp,"response.result.expenses[i].is_cogs")
        isduplicate = CkJsonObject::ckBoolOf(jResp,"response.result.expenses[i].isduplicate")
        markup_percent = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].markup_percent")
        notes = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].notes")
        profileid = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].profileid")
        project = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].project")
        projectid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].projectid")
        staffid = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].staffid")
        status = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].status")
        taxAmount1Amount = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].taxAmount1.amount")
        taxAmount1Code = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].taxAmount1.code")
        taxAmount2 = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].taxAmount2")
        taxName1 = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].taxName1")
        taxName2 = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].taxName2")
        taxPercent1 = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].taxPercent1")
        taxPercent2 = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].taxPercent2")
        transactionid = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].transactionid")
        updated = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].updated")
        vendor = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].vendor")
        vis_state = CkJsonObject::ckIntOf(jResp,"response.result.expenses[i].vis_state")
        attachment = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].attachment")
        taxAmount1 = CkJsonObject::ckStringOf(jResp,"response.result.expenses[i].taxAmount1")
        i = i + 1
    Wend


    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(queryParams)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkJsonObject::ckDispose(jResp)


    ProcedureReturn
EndProcedure

Curl Command

curl -G -d "include[]=attachment"
	-d "include[]=category"
	-d "include[]=expense_profile"
	-d "include[]=project"
	-d "include[]=account"
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
https://api.freshbooks.com/accounting/account/{{accountId}}/expenses/expenses

Postman Collection Item JSON

{
  "name": "List Expenses",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "let jsonData = JSON.parse(responseBody);",
          "pm.environment.set(\"expenseId\", jsonData.response.result.expenses[0].id)"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/expenses/expenses?include[]=attachment&include[]=category&include[]=expense_profile&include[]=project&include[]=account",
      "protocol": "https",
      "host": [
        "api",
        "freshbooks",
        "com"
      ],
      "path": [
        "accounting",
        "account",
        "{{accountId}}",
        "expenses",
        "expenses"
      ],
      "query": [
        {
          "key": "include[]",
          "value": "attachment",
          "description": "includes attachment details assocatied with expense receipts"
        },
        {
          "key": "include[]",
          "value": "category",
          "description": "include expense category in expense\n"
        },
        {
          "key": "include[]",
          "value": "expense_profile",
          "description": "include expense profile info in expense\n"
        },
        {
          "key": "include[]",
          "value": "project",
          "description": "include related projects in expense\n"
        },
        {
          "key": "include[]",
          "value": "account",
          "description": "include account info in expense\n"
        }
      ]
    },
    "description": "Get all expenses\t"
  },
  "response": [
    {
      "name": "List Expenses",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "https://api.freshbooks.com/accounting/account/{{accountId}}/expenses/expenses?include%5B%5D=attachment&include%5B%5D=category&include%5B%5D=expense_profile&include%5B%5D=project&include%5B%5D=account",
          "protocol": "https",
          "host": [
            "api",
            "freshbooks",
            "com"
          ],
          "path": [
            "accounting",
            "account",
            "{{accountId}}",
            "expenses",
            "expenses"
          ],
          "query": [
            {
              "key": "include%5B%5D",
              "value": "attachment",
              "description": "includes attachment details assocatied with expense receipts"
            },
            {
              "key": "include%5B%5D",
              "value": "category",
              "description": "include expense category in expense\n"
            },
            {
              "key": "include%5B%5D",
              "value": "expense_profile",
              "description": "include expense profile info in expense\n"
            },
            {
              "key": "include%5B%5D",
              "value": "project",
              "description": "include related projects in expense\n"
            },
            {
              "key": "include%5B%5D",
              "value": "account",
              "description": "include account info in expense\n"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "nginx"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        },
        {
          "key": "X-NewRelic-App-Data",
          "value": "PxQBWV5TCBABVlVSAwEOVlcTGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4DFVdfRgFPCkNFR0gBSUZWDBUGEQoHQBJdVkdXQEcVUR1RHVNWBw9UVVsKCwRXUVMABABeSBwHH0BXW1EBB1tbXQtVUAQAXFgBQx8EBVpEBDs="
        },
        {
          "key": "Access-Control-Allow-Origin",
          "value": "*"
        },
        {
          "key": "Expires",
          "value": "Mon, 30 Apr 2018 21:04:15 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": "Tue, 30 Apr 2019 21:04:16 GMT"
        },
        {
          "key": "Connection",
          "value": "keep-alive"
        },
        {
          "key": "X-Served-By",
          "value": "cache-mdw17339-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            \"expenses\": [\n                {\n                    \"account_name\": \"\",\n                    \"accountid\": null,\n                    \"accounting_systemid\": \"wkMd2g\",\n                    \"amount\": {\n                        \"amount\": \"79.73\",\n                        \"code\": \"USD\"\n                    },\n                    \"attachment\": {\n                        \"attachmentid\": 8668,\n                        \"id\": 8668,\n                        \"jwt\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6IlNjcmVlbiBTaG90IDIwMTktMDQtMjQgYXQgOS4zOS4xOSBBTS5wbmciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtMGU2ZDMwOWQ1ZTI5MzA3NmNhMGIyNDdkODFlOGJlNWE4NDZlZWE0YSIsImxlbmd0aCI6MTkxNDcyLCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTBlNmQzMDlkNWUyOTMwNzZjYTBiMjQ3ZDgxZThiZTVhODQ2ZWVhNGEifQ.SOoW3_nTUrxjYO76g1UXHPIrO_aLbTpXCHEa-ZcnejA\",\n                        \"media_type\": \"image/png\"\n                    },\n                    \"background_jobid\": null,\n                    \"bank_name\": \"\",\n                    \"category\": {\n                        \"category\": \"Gas\",\n                        \"categoryid\": 2003174,\n                        \"created_at\": \"2019-04-18 09:14:52\",\n                        \"id\": 2003174,\n                        \"is_cogs\": false,\n                        \"is_editable\": false,\n                        \"parentid\": 2003170,\n                        \"updated_at\": \"2019-04-18 09:14:52\",\n                        \"vis_state\": 0\n                    },\n                    \"categoryid\": 2003174,\n                    \"clientid\": 0,\n                    \"compounded_tax\": false,\n                    \"date\": \"2019-04-24\",\n                    \"expense_profile\": null,\n                    \"expenseid\": 1825568,\n                    \"ext_invoiceid\": 0,\n                    \"ext_systemid\": 0,\n                    \"from_bulk_import\": false,\n                    \"has_receipt\": true,\n                    \"id\": 1825568,\n                    \"include_receipt\": false,\n                    \"invoiceid\": null,\n                    \"is_cogs\": false,\n                    \"isduplicate\": true,\n                    \"markup_percent\": \"0\",\n                    \"notes\": \"Purchased Gasoline for deliveries\",\n                    \"profileid\": null,\n                    \"project\": null,\n                    \"projectid\": 0,\n                    \"staffid\": 1,\n                    \"status\": 0,\n                    \"taxAmount1\": {\n                        \"amount\": \"9.17\",\n                        \"code\": \"USD\"\n                    },\n                    \"taxAmount2\": null,\n                    \"taxName1\": \"other tax\",\n                    \"taxName2\": null,\n                    \"taxPercent1\": \"13\",\n                    \"taxPercent2\": null,\n                    \"transactionid\": null,\n                    \"updated\": \"2019-04-24 11:33:35\",\n                    \"vendor\": \"Shell Gas Station\",\n                    \"vis_state\": 0\n                },\n                {\n                    \"account_name\": \"\",\n                    \"accountid\": null,\n                    \"accounting_systemid\": \"wkMd2g\",\n                    \"amount\": {\n                        \"amount\": \"79.73\",\n                        \"code\": \"USD\"\n                    },\n                    \"attachment\": {\n                        \"attachmentid\": 8670,\n                        \"id\": 8670,\n                        \"jwt\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6IlNjcmVlbiBTaG90IDIwMTktMDQtMjQgYXQgOS4zOS4xOSBBTS5wbmciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtMGU2ZDMwOWQ1ZTI5MzA3NmNhMGIyNDdkODFlOGJlNWE4NDZlZWE0YSIsImxlbmd0aCI6MTkxNDcyLCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTBlNmQzMDlkNWUyOTMwNzZjYTBiMjQ3ZDgxZThiZTVhODQ2ZWVhNGEifQ.SOoW3_nTUrxjYO76g1UXHPIrO_aLbTpXCHEa-ZcnejA\",\n                        \"media_type\": \"image/png\"\n                    },\n                    \"background_jobid\": null,\n                    \"bank_name\": \"\",\n                    \"category\": {\n                        \"category\": \"Gas\",\n                        \"categoryid\": 2003174,\n                        \"created_at\": \"2019-04-18 09:14:52\",\n                        \"id\": 2003174,\n                        \"is_cogs\": false,\n                        \"is_editable\": false,\n                        \"parentid\": 2003170,\n                        \"updated_at\": \"2019-04-18 09:14:52\",\n                        \"vis_state\": 0\n                    },\n                    \"categoryid\": 2003174,\n                    \"clientid\": 0,\n                    \"compounded_tax\": false,\n                    \"date\": \"2019-04-24\",\n                    \"expense_profile\": null,\n                    \"expenseid\": 1825574,\n                    \"ext_invoiceid\": 0,\n                    \"ext_systemid\": 0,\n                    \"from_bulk_import\": false,\n                    \"has_receipt\": true,\n                    \"id\": 1825574,\n                    \"include_receipt\": false,\n                    \"invoiceid\": null,\n                    \"is_cogs\": false,\n                    \"isduplicate\": true,\n                    \"markup_percent\": \"0\",\n                    \"notes\": \"Purchased Gasoline for deliveries\",\n                    \"profileid\": null,\n                    \"project\": null,\n                    \"projectid\": 0,\n                    \"staffid\": 1,\n                    \"status\": 0,\n                    \"taxAmount1\": {\n                        \"amount\": \"9.17\",\n                        \"code\": \"USD\"\n                    },\n                    \"taxAmount2\": null,\n                    \"taxName1\": \"other tax\",\n                    \"taxName2\": null,\n                    \"taxPercent1\": \"13\",\n                    \"taxPercent2\": null,\n                    \"transactionid\": null,\n                    \"updated\": \"2019-04-24 11:38:00\",\n                    \"vendor\": \"Shell Gas Station\",\n                    \"vis_state\": 2\n                },\n                {\n                    \"account_name\": \"\",\n                    \"accountid\": null,\n                    \"accounting_systemid\": \"wkMd2g\",\n                    \"amount\": {\n                        \"amount\": \"79.73\",\n                        \"code\": \"USD\"\n                    },\n                    \"attachment\": {\n                        \"attachmentid\": 12138,\n                        \"id\": 12138,\n                        \"jwt\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6IlNjcmVlbiBTaG90IDIwMTktMDQtMjQgYXQgOS4zOS4xOSBBTS5wbmciLCJidWNrZXQiOiJ1cGxvYWRzIiwiZmlsZW5hbWUiOiJ1cGxvYWQtMGU2ZDMwOWQ1ZTI5MzA3NmNhMGIyNDdkODFlOGJlNWE4NDZlZWE0YSIsImxlbmd0aCI6MTkxNDcyLCJrZXkiOiInZG9jcy0nLTQyMzY0MTAvdXBsb2FkLTBlNmQzMDlkNWUyOTMwNzZjYTBiMjQ3ZDgxZThiZTVhODQ2ZWVhNGEifQ.SOoW3_nTUrxjYO76g1UXHPIrO_aLbTpXCHEa-ZcnejA\",\n                        \"media_type\": \"image/png\"\n                    },\n                    \"background_jobid\": null,\n                    \"bank_name\": \"\",\n                    \"category\": {\n                        \"category\": \"Gas\",\n                        \"categoryid\": 2003174,\n                        \"created_at\": \"2019-04-18 09:14:52\",\n                        \"id\": 2003174,\n                        \"is_cogs\": false,\n                        \"is_editable\": false,\n                        \"parentid\": 2003170,\n                        \"updated_at\": \"2019-04-18 09:14:52\",\n                        \"vis_state\": 0\n                    },\n                    \"categoryid\": 2003174,\n                    \"clientid\": 0,\n                    \"compounded_tax\": false,\n                    \"date\": \"2019-04-24\",\n                    \"expense_profile\": null,\n                    \"expenseid\": 2721846,\n                    \"ext_invoiceid\": 0,\n                    \"ext_systemid\": 0,\n                    \"from_bulk_import\": false,\n                    \"has_receipt\": true,\n                    \"id\": 2721846,\n                    \"include_receipt\": false,\n                    \"invoiceid\": null,\n                    \"is_cogs\": false,\n                    \"isduplicate\": true,\n                    \"markup_percent\": \"0\",\n                    \"notes\": \"Purchased Gasoline for deliveries\",\n                    \"profileid\": null,\n                    \"project\": null,\n                    \"projectid\": 0,\n                    \"staffid\": 1,\n                    \"status\": 0,\n                    \"taxAmount1\": {\n                        \"amount\": \"9.17\",\n                        \"code\": \"USD\"\n                    },\n                    \"taxAmount2\": null,\n                    \"taxName1\": \"other tax\",\n                    \"taxName2\": null,\n                    \"taxPercent1\": \"13\",\n                    \"taxPercent2\": null,\n                    \"transactionid\": null,\n                    \"updated\": \"2019-04-30 16:48:22\",\n                    \"vendor\": \"Shell Gas Station\",\n                    \"vis_state\": 0\n                },\n                {\n                    \"account_name\": \"\",\n                    \"accountid\": null,\n                    \"accounting_systemid\": \"wkMd2g\",\n                    \"amount\": {\n                        \"amount\": \"7000.99\",\n                        \"code\": \"USD\"\n                    },\n                    \"attachment\": {\n                        \"attachmentid\": 6122,\n                        \"id\": 6122,\n                        \"jwt\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50Ijo0MjM2NDEwLCJvcmlnaW5hbF9maWxlbmFtZSI6IlNjcmVlbiBTaG90IDIwMTktMDQtMTYgYXQgMTEuMzcuMjEgQU0ucG5nIiwiYnVja2V0IjoidXBsb2FkcyIsImZpbGVuYW1lIjoidXBsb2FkLTJjMDY0NDEwZDQwYjE1NTRkZTAyM2Q1MjNlNmJjOTA3NDMyYmIwMGMiLCJsZW5ndGgiOjE0NTk2MCwia2V5IjoiJ2RvY3MtJy00MjM2NDEwL3VwbG9hZC0yYzA2NDQxMGQ0MGIxNTU0ZGUwMjNkNTIzZTZiYzkwNzQzMmJiMDBjIn0.MogtZWv_c3mllnjMzX5DEP2J5PBsEa1ZfHwdXgywRoM\",\n                        \"media_type\": \"image/png\"\n                    },\n                    \"background_jobid\": null,\n                    \"bank_name\": \"\",\n                    \"category\": {\n                        \"category\": \"Computer Parts\",\n                        \"categoryid\": 2005674,\n                        \"created_at\": \"2019-04-18 09:40:57\",\n                        \"id\": 2005674,\n                        \"is_cogs\": false,\n                        \"is_editable\": true,\n                        \"parentid\": 2003142,\n                        \"updated_at\": \"2019-04-18 09:40:57\",\n                        \"vis_state\": 0\n                    },\n                    \"categoryid\": 2005674,\n                    \"clientid\": 0,\n                    \"compounded_tax\": false,\n                    \"date\": \"2019-04-18\",\n                    \"expense_profile\": null,\n                    \"expenseid\": 1034972,\n                    \"ext_invoiceid\": 0,\n                    \"ext_systemid\": 0,\n                    \"from_bulk_import\": false,\n                    \"has_receipt\": true,\n                    \"id\": 1034972,\n                    \"include_receipt\": false,\n                    \"invoiceid\": null,\n                    \"is_cogs\": false,\n                    \"isduplicate\": false,\n                    \"markup_percent\": \"0\",\n                    \"notes\": \"Need the parts to make the computer hardware\",\n                    \"profileid\": null,\n                    \"project\": null,\n                    \"projectid\": 0,\n                    \"staffid\": 1,\n                    \"status\": 0,\n                    \"taxAmount1\": {\n                        \"amount\": \"805.42\",\n                        \"code\": \"USD\"\n                    },\n                    \"taxAmount2\": null,\n                    \"taxName1\": \"HST\",\n                    \"taxName2\": null,\n                    \"taxPercent1\": \"13\",\n                    \"taxPercent2\": null,\n                    \"transactionid\": null,\n                    \"updated\": \"2019-04-18 09:41:44\",\n                    \"vendor\": \"Computer Parts People\",\n                    \"vis_state\": 0\n                },\n                {\n                    \"account_name\": \"\",\n                    \"accountid\": null,\n                    \"accounting_systemid\": \"wkMd2g\",\n                    \"amount\": {\n                        \"amount\": \"39.991\",\n                        \"code\": \"USD\"\n                    },\n                    \"attachment\": null,\n                    \"background_jobid\": null,\n                    \"bank_name\": \"\",\n                    \"category\": {\n                        \"category\": \"Equipment\",\n                        \"categoryid\": 2003232,\n                        \"created_at\": \"2019-04-18 09:14:52\",\n                        \"id\": 2003232,\n                        \"is_cogs\": false,\n                        \"is_editable\": false,\n                        \"parentid\": 2003226,\n                        \"updated_at\": \"2019-04-18 09:14:52\",\n                        \"vis_state\": 0\n                    },\n                    \"categoryid\": 2003232,\n                    \"clientid\": 0,\n                    \"compounded_tax\": false,\n                    \"date\": \"2018-06-20\",\n                    \"expense_profile\": null,\n                    \"expenseid\": 1553548,\n                    \"ext_invoiceid\": 0,\n                    \"ext_systemid\": 0,\n                    \"from_bulk_import\": false,\n                    \"has_receipt\": false,\n                    \"id\": 1553548,\n                    \"include_receipt\": false,\n                    \"invoiceid\": null,\n                    \"is_cogs\": false,\n                    \"isduplicate\": false,\n                    \"markup_percent\": \"0\",\n                    \"notes\": \"\",\n                    \"profileid\": null,\n                    \"project\": null,\n                    \"projectid\": 0,\n                    \"staffid\": 31004,\n                    \"status\": 0,\n                    \"taxAmount1\": null,\n                    \"taxAmount2\": null,\n                    \"taxName1\": null,\n                    \"taxName2\": null,\n                    \"taxPercent1\": null,\n                    \"taxPercent2\": null,\n                    \"transactionid\": null,\n                    \"updated\": \"2019-04-24 11:39:15\",\n                    \"vendor\": null,\n                    \"vis_state\": 0\n                }\n            ],\n            \"page\": 1,\n            \"pages\": 1,\n            \"per_page\": 15,\n            \"total\": 5\n        }\n    }\n}"
    }
  ]
}