Sample code for 30+ languages & platforms
Unicode C

Quickbooks Send an Invoice

See more QuickBooks Examples

Demonstrates how to send an invoice using the Quickbooks REST API.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkJsonObjectW.h>
#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkJsonObjectW jsonToken;
    HCkRestW rest;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilderW sbAuth;
    HCkStringBuilderW sbResponseBody;
    int respStatusCode;
    HCkJsonObjectW jsonResponse;
    const wchar_t *Description;
    const wchar_t *DetailType;
    const wchar_t *SalesItemLineDetailTaxCodeRefValue;
    int SalesItemLineDetailQty;
    int SalesItemLineDetailUnitPrice;
    const wchar_t *SalesItemLineDetailServiceDate;
    const wchar_t *SalesItemLineDetailItemRefName;
    const wchar_t *SalesItemLineDetailItemRefValue;
    int LineNum;
    const wchar_t *Amount;
    const wchar_t *Id;
    const wchar_t *DiscountLineDetailDiscountAccountRefName;
    const wchar_t *DiscountLineDetailDiscountAccountRefValue;
    BOOL DiscountLineDetailPercentBased;
    int DiscountLineDetailDiscountPercent;
    const wchar_t *TaxLineDetailNetAmountTaxable;
    int TaxLineDetailTaxPercent;
    const wchar_t *TaxLineDetailTaxRateRefValue;
    BOOL TaxLineDetailPercentBased;
    const wchar_t *StringValue;
    const wchar_t *Type;
    const wchar_t *Name;
    const wchar_t *InvoiceTxnDate;
    const wchar_t *InvoiceDomain;
    const wchar_t *InvoiceCurrencyRefName;
    const wchar_t *InvoiceCurrencyRefValue;
    const wchar_t *InvoiceShipDate;
    const wchar_t *InvoiceTrackingNum;
    const wchar_t *InvoiceClassRefName;
    const wchar_t *InvoiceClassRefValue;
    const wchar_t *InvoicePrintStatus;
    const wchar_t *InvoiceSalesTermRefValue;
    const wchar_t *InvoiceDeliveryInfoDeliveryType;
    const wchar_t *InvoiceDeliveryInfoDeliveryTime;
    const wchar_t *InvoiceTotalAmt;
    const wchar_t *InvoiceDueDate;
    const wchar_t *InvoiceMetaDataCreateTime;
    const wchar_t *InvoiceMetaDataLastUpdatedTime;
    const wchar_t *InvoiceDocNumber;
    const wchar_t *InvoicePrivateNote;
    BOOL InvoiceSparse;
    const wchar_t *InvoiceDepositToAccountRefName;
    const wchar_t *InvoiceDepositToAccountRefValue;
    const wchar_t *InvoiceCustomerMemoValue;
    const wchar_t *InvoiceEmailStatus;
    const wchar_t *InvoiceDeposit;
    const wchar_t *InvoiceBalance;
    const wchar_t *InvoiceCustomerRefName;
    const wchar_t *InvoiceCustomerRefValue;
    const wchar_t *InvoiceTxnTaxDetailTxnTaxCodeRefValue;
    const wchar_t *InvoiceTxnTaxDetailTotalTax;
    const wchar_t *InvoiceSyncToken;
    const wchar_t *InvoiceBillEmailAddress;
    const wchar_t *InvoiceShipAddrCity;
    const wchar_t *InvoiceShipAddrCountry;
    const wchar_t *InvoiceShipAddrLine5;
    const wchar_t *InvoiceShipAddrLine4;
    const wchar_t *InvoiceShipAddrLine3;
    const wchar_t *InvoiceShipAddrLine2;
    const wchar_t *InvoiceShipAddrLine1;
    const wchar_t *InvoiceShipAddrPostalCode;
    const wchar_t *InvoiceShipAddrLat;
    const wchar_t *InvoiceShipAddrLong;
    const wchar_t *InvoiceShipAddrCountrySubDivisionCode;
    const wchar_t *InvoiceShipAddrId;
    const wchar_t *InvoiceDepartmentRefName;
    const wchar_t *InvoiceDepartmentRefValue;
    const wchar_t *InvoiceShipMethodRefName;
    const wchar_t *InvoiceShipMethodRefValue;
    const wchar_t *InvoiceBillAddrCity;
    const wchar_t *InvoiceBillAddrCountry;
    const wchar_t *InvoiceBillAddrLine5;
    const wchar_t *InvoiceBillAddrLine4;
    const wchar_t *InvoiceBillAddrLine3;
    const wchar_t *InvoiceBillAddrLine2;
    const wchar_t *InvoiceBillAddrLine1;
    const wchar_t *InvoiceBillAddrPostalCode;
    const wchar_t *InvoiceBillAddrLat;
    const wchar_t *InvoiceBillAddrLong;
    const wchar_t *InvoiceBillAddrCountrySubDivisionCode;
    const wchar_t *InvoiceBillAddrId;
    BOOL InvoiceApplyTaxAfterDiscount;
    const wchar_t *InvoiceId;
    const wchar_t *time;
    int i;
    int count_i;

    success = FALSE;

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

    // First get our previously obtained OAuth2 access token.
    jsonToken = CkJsonObjectW_Create();
    success = CkJsonObjectW_LoadFile(jsonToken,L"qa_data/tokens/qb-access-token.json");

    rest = CkRestW_Create();

    // Connect to the REST server.
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRestW_Connect(rest,L"sandbox-quickbooks.api.intuit.com",port,bTls,bAutoReconnect);

    sbAuth = CkStringBuilderW_Create();
    CkStringBuilderW_Append(sbAuth,L"Bearer ");
    CkStringBuilderW_Append(sbAuth,CkJsonObjectW_stringOf(jsonToken,L"access_token"));
    CkRestW_putAuthorization(rest,CkStringBuilderW_getAsString(sbAuth));

    // --------------------------------------------------------------------------
    // Note: The above code to setup the initial REST connection
    // can be done once.  After connecting, any number of REST calls can be made.
    // If the connection is lost, the next REST method call will automatically
    // reconnect if needed.
    // --------------------------------------------------------------------------

    // Technically, the POST has an empty request body, but the Quickbooks documentation indicates that 
    // the Content-Type header should be set to "application/octet-stream", which really makes no sense
    // because there is not content. (How can no content have a type???)
    CkRestW_AddHeader(rest,L"Content-Type",L"application/octet-stream");
    CkRestW_putAllowHeaderFolding(rest,FALSE);

    sbResponseBody = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"POST",L"/v3/company/<realmID>/invoice/<invoiceId>/send?sendTo=<emailAddr>",sbResponseBody);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkJsonObjectW_Dispose(jsonToken);
        CkRestW_Dispose(rest);
        CkStringBuilderW_Dispose(sbAuth);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    respStatusCode = CkRestW_getResponseStatusCode(rest);

    // Success is indicated by a 200 response status code.
    wprintf(L"response status code = %d\n",respStatusCode);

    jsonResponse = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jsonResponse,FALSE);
    wprintf(L"%s\n",CkJsonObjectW_emit(jsonResponse));

    if (CkRestW_getResponseStatusCode(rest) != 200) {
        wprintf(L"Failed.\n");
        CkJsonObjectW_Dispose(jsonToken);
        CkRestW_Dispose(rest);
        CkStringBuilderW_Dispose(sbAuth);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jsonResponse);
        return;
    }

    // Sample output...
    // (See the parsing code below..)
    // 
    // Use the this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    // {
    //   "Invoice": {
    //     "TxnDate": "2013-03-14",
    //     "domain": "QBO",
    //     "CurrencyRef": {
    //       "name": "United States Dollar",
    //       "value": "USD"
    //     },
    //     "ShipDate": "2013-03-01",
    //     "TrackingNum": "123456789",
    //     "ClassRef": {
    //       "name": "Class 1",
    //       "value": "200900000000000003901"
    //     },
    //     "PrintStatus": "NeedToPrint",
    //     "SalesTermRef": {
    //       "value": "4"
    //     },
    //     "DeliveryInfo": {
    //       "DeliveryType": "Email",
    //       "DeliveryTime": "2014-12-17T11:50:52-08:00"
    //     },
    //     "TotalAmt": 52.0,
    //     "Line": [
    //       {
    //         "Description": "Sample invoice create request",
    //         "DetailType": "SalesItemLineDetail",
    //         "SalesItemLineDetail": {
    //           "TaxCodeRef": {
    //             "value": "TAX"
    //           },
    //           "Qty": 1,
    //           "UnitPrice": 50,
    //           "ServiceDate": "2013-03-04",
    //           "ItemRef": {
    //             "name": "Hours",
    //             "value": "2"
    //           }
    //         },
    //         "LineNum": 1,
    //         "Amount": 50.0,
    //         "Id": "1"
    //       },
    //       {
    //         "DetailType": "SubTotalLineDetail",
    //         "Amount": 50.0,
    //         "SubTotalLineDetail": {}
    //       },
    //       {
    //         "DetailType": "DiscountLineDetail",
    //         "Amount": 5.0,
    //         "DiscountLineDetail": {
    //           "DiscountAccountRef": {
    //             "name": "Discounts given",
    //             "value": "30"
    //           },
    //           "PercentBased": true,
    //           "DiscountPercent": 10
    //         }
    //       },
    //       {
    //         "DetailType": "SalesItemLineDetail",
    //         "Amount": 2.0,
    //         "SalesItemLineDetail": {
    //           "ItemRef": {
    //             "value": "SHIPPING_ITEM_ID"
    //           }
    //         }
    //       }
    //     ],
    //     "DueDate": "2013-05-13",
    //     "MetaData": {
    //       "CreateTime": "2013-03-14T01:42:16-07:00",
    //       "LastUpdatedTime": "2014-12-17T11:50:58-08:00"
    //     },
    //     "DocNumber": "Sample_Inv#2",
    //     "PrivateNote": "Summary for sample invoice",
    //     "sparse": false,
    //     "DepositToAccountRef": {
    //       "name": "Undeposited Funds",
    //       "value": "4"
    //     },
    //     "CustomerMemo": {
    //       "value": "This is the customer message"
    //     },
    //     "EmailStatus": "EmailSent",
    //     "Deposit": 12.0,
    //     "Balance": 40.0,
    //     "CustomerRef": {
    //       "name": "Mr V3 Service Customer Jr2",
    //       "value": "15"
    //     },
    //     "TxnTaxDetail": {
    //       "TxnTaxCodeRef": {
    //         "value": "5"
    //       },
    //       "TotalTax": 5.0,
    //       "TaxLine": [
    //         {
    //           "DetailType": "TaxLineDetail",
    //           "Amount": 5.0,
    //           "TaxLineDetail": {
    //             "NetAmountTaxable": 50.0,
    //             "TaxPercent": 10,
    //             "TaxRateRef": {
    //               "value": "2"
    //             },
    //             "PercentBased": true
    //           }
    //         }
    //       ]
    //     },
    //     "SyncToken": "0",
    //     "BillEmail": {
    //       "Address": "test@intuit.com"
    //     },
    //     "ShipAddr": {
    //       "City": "San Jose",
    //       "Country": "USA",
    //       "Line5": "Cube 999",
    //       "Line4": "Dept 12",
    //       "Line3": "123 street",
    //       "Line2": "Building 1",
    //       "Line1": "Intuit",
    //       "PostalCode": "95123",
    //       "Lat": "37.2374847",
    //       "Long": "-121.8277925",
    //       "CountrySubDivisionCode": "CA",
    //       "Id": "36"
    //     },
    //     "DepartmentRef": {
    //       "name": "Mountain View",
    //       "value": "1"
    //     },
    //     "ShipMethodRef": {
    //       "name": "UPS",
    //       "value": "UPS"
    //     },
    //     "BillAddr": {
    //       "City": "Mountain View",
    //       "Country": "USA",
    //       "Line5": "Cube 999",
    //       "Line4": "Dept 12",
    //       "Line3": "123 street",
    //       "Line2": "Building 1",
    //       "Line1": "Google",
    //       "PostalCode": "95123",
    //       "Lat": "37.2374847",
    //       "Long": "-121.8277925",
    //       "CountrySubDivisionCode": "CA",
    //       "Id": "35"
    //     },
    //     "ApplyTaxAfterDiscount": false,
    //     "CustomField": [
    //       {
    //         "StringValue": "Custom1",
    //         "Type": "StringType",
    //         "Name": "Custom 1"
    //       },
    //       {
    //         "StringValue": "Custom2",
    //         "Type": "StringType",
    //         "Name": "Custom 2"
    //       },
    //       {
    //         "StringValue": "Custom3",
    //         "Type": "StringType",
    //         "Name": "Custom 3"
    //       }
    //     ],
    //     "Id": "96"
    //   },
    //   "time": "2013-03-14T13:32:04.895-07:00"
    // }
    // 

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    InvoiceTxnDate = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TxnDate");
    InvoiceDomain = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.domain");
    InvoiceCurrencyRefName = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.CurrencyRef.name");
    InvoiceCurrencyRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.CurrencyRef.value");
    InvoiceShipDate = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipDate");
    InvoiceTrackingNum = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TrackingNum");
    InvoiceClassRefName = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ClassRef.name");
    InvoiceClassRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ClassRef.value");
    InvoicePrintStatus = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.PrintStatus");
    InvoiceSalesTermRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.SalesTermRef.value");
    InvoiceDeliveryInfoDeliveryType = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.DeliveryInfo.DeliveryType");
    InvoiceDeliveryInfoDeliveryTime = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.DeliveryInfo.DeliveryTime");
    InvoiceTotalAmt = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TotalAmt");
    InvoiceDueDate = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.DueDate");
    InvoiceMetaDataCreateTime = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.MetaData.CreateTime");
    InvoiceMetaDataLastUpdatedTime = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.MetaData.LastUpdatedTime");
    InvoiceDocNumber = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.DocNumber");
    InvoicePrivateNote = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.PrivateNote");
    InvoiceSparse = CkJsonObjectW_BoolOf(jsonResponse,L"Invoice.sparse");
    InvoiceDepositToAccountRefName = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.DepositToAccountRef.name");
    InvoiceDepositToAccountRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.DepositToAccountRef.value");
    InvoiceCustomerMemoValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.CustomerMemo.value");
    InvoiceEmailStatus = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.EmailStatus");
    InvoiceDeposit = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Deposit");
    InvoiceBalance = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Balance");
    InvoiceCustomerRefName = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.CustomerRef.name");
    InvoiceCustomerRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.CustomerRef.value");
    InvoiceTxnTaxDetailTxnTaxCodeRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TxnTaxDetail.TxnTaxCodeRef.value");
    InvoiceTxnTaxDetailTotalTax = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TxnTaxDetail.TotalTax");
    InvoiceSyncToken = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.SyncToken");
    InvoiceBillEmailAddress = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillEmail.Address");
    InvoiceShipAddrCity = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.City");
    InvoiceShipAddrCountry = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Country");
    InvoiceShipAddrLine5 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Line5");
    InvoiceShipAddrLine4 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Line4");
    InvoiceShipAddrLine3 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Line3");
    InvoiceShipAddrLine2 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Line2");
    InvoiceShipAddrLine1 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Line1");
    InvoiceShipAddrPostalCode = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.PostalCode");
    InvoiceShipAddrLat = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Lat");
    InvoiceShipAddrLong = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Long");
    InvoiceShipAddrCountrySubDivisionCode = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.CountrySubDivisionCode");
    InvoiceShipAddrId = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipAddr.Id");
    InvoiceDepartmentRefName = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.DepartmentRef.name");
    InvoiceDepartmentRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.DepartmentRef.value");
    InvoiceShipMethodRefName = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipMethodRef.name");
    InvoiceShipMethodRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.ShipMethodRef.value");
    InvoiceBillAddrCity = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.City");
    InvoiceBillAddrCountry = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Country");
    InvoiceBillAddrLine5 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Line5");
    InvoiceBillAddrLine4 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Line4");
    InvoiceBillAddrLine3 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Line3");
    InvoiceBillAddrLine2 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Line2");
    InvoiceBillAddrLine1 = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Line1");
    InvoiceBillAddrPostalCode = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.PostalCode");
    InvoiceBillAddrLat = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Lat");
    InvoiceBillAddrLong = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Long");
    InvoiceBillAddrCountrySubDivisionCode = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.CountrySubDivisionCode");
    InvoiceBillAddrId = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.BillAddr.Id");
    InvoiceApplyTaxAfterDiscount = CkJsonObjectW_BoolOf(jsonResponse,L"Invoice.ApplyTaxAfterDiscount");
    InvoiceId = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Id");
    time = CkJsonObjectW_stringOf(jsonResponse,L"time");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"Invoice.Line");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        Description = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].Description");
        DetailType = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].DetailType");
        SalesItemLineDetailTaxCodeRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].SalesItemLineDetail.TaxCodeRef.value");
        SalesItemLineDetailQty = CkJsonObjectW_IntOf(jsonResponse,L"Invoice.Line[i].SalesItemLineDetail.Qty");
        SalesItemLineDetailUnitPrice = CkJsonObjectW_IntOf(jsonResponse,L"Invoice.Line[i].SalesItemLineDetail.UnitPrice");
        SalesItemLineDetailServiceDate = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].SalesItemLineDetail.ServiceDate");
        SalesItemLineDetailItemRefName = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].SalesItemLineDetail.ItemRef.name");
        SalesItemLineDetailItemRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].SalesItemLineDetail.ItemRef.value");
        LineNum = CkJsonObjectW_IntOf(jsonResponse,L"Invoice.Line[i].LineNum");
        Amount = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].Amount");
        Id = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].Id");
        DiscountLineDetailDiscountAccountRefName = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].DiscountLineDetail.DiscountAccountRef.name");
        DiscountLineDetailDiscountAccountRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.Line[i].DiscountLineDetail.DiscountAccountRef.value");
        DiscountLineDetailPercentBased = CkJsonObjectW_BoolOf(jsonResponse,L"Invoice.Line[i].DiscountLineDetail.PercentBased");
        DiscountLineDetailDiscountPercent = CkJsonObjectW_IntOf(jsonResponse,L"Invoice.Line[i].DiscountLineDetail.DiscountPercent");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"Invoice.TxnTaxDetail.TaxLine");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        DetailType = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TxnTaxDetail.TaxLine[i].DetailType");
        Amount = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TxnTaxDetail.TaxLine[i].Amount");
        TaxLineDetailNetAmountTaxable = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TxnTaxDetail.TaxLine[i].TaxLineDetail.NetAmountTaxable");
        TaxLineDetailTaxPercent = CkJsonObjectW_IntOf(jsonResponse,L"Invoice.TxnTaxDetail.TaxLine[i].TaxLineDetail.TaxPercent");
        TaxLineDetailTaxRateRefValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.TxnTaxDetail.TaxLine[i].TaxLineDetail.TaxRateRef.value");
        TaxLineDetailPercentBased = CkJsonObjectW_BoolOf(jsonResponse,L"Invoice.TxnTaxDetail.TaxLine[i].TaxLineDetail.PercentBased");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jsonResponse,L"Invoice.CustomField");
    while (i < count_i) {
        CkJsonObjectW_putI(jsonResponse,i);
        StringValue = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.CustomField[i].StringValue");
        Type = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.CustomField[i].Type");
        Name = CkJsonObjectW_stringOf(jsonResponse,L"Invoice.CustomField[i].Name");
        i = i + 1;
    }



    CkJsonObjectW_Dispose(jsonToken);
    CkRestW_Dispose(rest);
    CkStringBuilderW_Dispose(sbAuth);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jsonResponse);

    }