Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) Quickbooks Query an Invoice

Demonstrates how to query for invoices matching a SELECT statement via the Quickbooks REST API.

For more information, see https://www.developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/invoice#query-an-invoice

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
Token    Handle hoJsonToken
    Boolean iSuccess
    Handle hoRest
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    Boolean iSuccess
    Handle hoSbAuth
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJson
    String sDocNumber
    String sSyncToken
    String sDomain
    String sBalance
    String sBillAddrCity
    String sBillAddrLine1
    String sBillAddrPostalCode
    String sBillAddrLat
    String sBillAddrLong
    String sBillAddrCountrySubDivisionCode
    String sBillAddrId
    String sTxnDate
    String sTotalAmt
    String sCustomerRefName
    String sCustomerRefValue
    String sShipAddrCity
    String sShipAddrLine1
    String sShipAddrPostalCode
    String sShipAddrLat
    String sShipAddrLong
    String sShipAddrCountrySubDivisionCode
    String sShipAddrId
    String sDueDate
    String sPrintStatus
    Integer iDeposit
    Boolean iSparse
    String sEmailStatus
    Boolean iApplyTaxAfterDiscount
    String sId
    Integer iTxnTaxDetailTotalTax
    String sMetaDataCreateTime
    String sMetaDataLastUpdatedTime
    Integer j
    Integer iCount_j
    Integer iLineNum
    String sAmount
    String sSalesItemLineDetailTaxCodeRefValue
    String sSalesItemLineDetailItemRefName
    String sSalesItemLineDetailItemRefValue
    String sDetailType
    String sDefinitionId
    String sInvType
    String sName
    Integer iQueryResponseStartPosition
    Integer iQueryResponseTotalCount
    Integer iQueryResponseMaxResults
    String sTime
    Integer i
    Integer iCount_i
    String sTemp1

    // 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.
    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken
    If (Not(IsComObjectCreated(hoJsonToken))) Begin
        Send CreateComObject of hoJsonToken
    End
    Get ComLoadFile Of hoJsonToken "qa_data/tokens/qb-access-token.json" To iSuccess

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Move True To iBTls
    Move 443 To iPort
    Move True To iBAutoReconnect
    Get ComConnect Of hoRest "sandbox-quickbooks.api.intuit.com" iPort iBTls iBAutoReconnect To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbAuth
    If (Not(IsComObjectCreated(hoSbAuth))) Begin
        Send CreateComObject of hoSbAuth
    End
    Get ComAppend Of hoSbAuth "Bearer " To iSuccess
    Get ComStringOf Of hoJsonToken "access_token" To sTemp1
    Get ComAppend Of hoSbAuth sTemp1 To iSuccess
    Get ComGetAsString Of hoSbAuth To sTemp1
    Set ComAuthorization Of hoRest To sTemp1

    // --------------------------------------------------------------------------
    // Note: The above REST connection and setup of the AWS credentials
    // can be done once.  After connecting, any number of REST calls can be made.
    // The "auto reconnect" property passed to rest.Connect indicates that if
    // the connection is lost, a REST method call will automatically reconnect
    // if needed.
    // --------------------------------------------------------------------------

    // This is a GET request, so there should be no Content-Type
    // This line of code is just to make sure..
    Get ComRemoveHeader Of hoRest "Content-Type" To iSuccess

    Get ComAddHeader Of hoRest "Accept" "application/json" To iSuccess
    Set ComAllowHeaderFolding Of hoRest To False

    // Add a SELECT statement 
    Get ComAddQueryParam Of hoRest "query" "select * from Invoice where id = '239'" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestNoBodySb Of hoRest "GET" "/v3/company/<realmID>/invoice" vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Status Code = " iRespStatusCode
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Success is indicated by a 200 response status.
    Showln "response status code = " iRespStatusCode

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJson vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJson To False
    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // Sample output:
    // Use the this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    // {
    //   "QueryResponse": {
    //     "startPosition": 1, 
    //     "totalCount": 1, 
    //     "maxResults": 1, 
    //     "Invoice": [
    //       {
    //         "DocNumber": "1070", 
    //         "SyncToken": "0", 
    //         "domain": "QBO", 
    //         "Balance": 150.0, 
    //         "BillAddr": {
    //           "City": "Bayshore", 
    //           "Line1": "4581 Finch St.", 
    //           "PostalCode": "94326", 
    //           "Lat": "INVALID", 
    //           "Long": "INVALID", 
    //           "CountrySubDivisionCode": "CA", 
    //           "Id": "2"
    //         }, 
    //         "TxnDate": "2015-07-24", 
    //         "TotalAmt": 150.0, 
    //         "CustomerRef": {
    //           "name": "Amy's Bird Sanctuary", 
    //           "value": "1"
    //         }, 
    //         "ShipAddr": {
    //           "City": "Bayshore", 
    //           "Line1": "4581 Finch St.", 
    //           "PostalCode": "94326", 
    //           "Lat": "INVALID", 
    //           "Long": "INVALID", 
    //           "CountrySubDivisionCode": "CA", 
    //           "Id": "109"
    //         }, 
    //         "LinkedTxn": [], 
    //         "DueDate": "2015-08-23", 
    //         "PrintStatus": "NeedToPrint", 
    //         "Deposit": 0, 
    //         "sparse": false, 
    //         "EmailStatus": "NotSet", 
    //         "Line": [
    //           {
    //             "LineNum": 1, 
    //             "Amount": 150.0, 
    //             "SalesItemLineDetail": {
    //               "TaxCodeRef": {
    //                 "value": "NON"
    //               }, 
    //               "ItemRef": {
    //                 "name": "Services", 
    //                 "value": "1"
    //               }
    //             }, 
    //             "Id": "1", 
    //             "DetailType": "SalesItemLineDetail"
    //           }, 
    //           {
    //             "DetailType": "SubTotalLineDetail", 
    //             "Amount": 150.0, 
    //             "SubTotalLineDetail": {}
    //           }
    //         ], 
    //         "ApplyTaxAfterDiscount": false, 
    //         "CustomField": [
    //           {
    //             "DefinitionId": "1", 
    //             "Type": "StringType", 
    //             "Name": "Crew #"
    //           }
    //         ], 
    //         "Id": "239", 
    //         "TxnTaxDetail": {
    //           "TotalTax": 0
    //         }, 
    //         "MetaData": {
    //           "CreateTime": "2015-07-24T10:35:08-07:00", 
    //           "LastUpdatedTime": "2015-07-24T10:35:08-07:00"
    //         }
    //       }
    //     ]
    //   }, 
    //   "time": "2015-07-24T10:38:50.01-07:00"
    // }

    Get ComIntOf Of hoJson "QueryResponse.startPosition" To iQueryResponseStartPosition
    Get ComIntOf Of hoJson "QueryResponse.totalCount" To iQueryResponseTotalCount
    Get ComIntOf Of hoJson "QueryResponse.maxResults" To iQueryResponseMaxResults
    Get ComStringOf Of hoJson "time" To sTime
    Move 0 To i
    Get ComSizeOfArray Of hoJson "QueryResponse.Invoice" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].DocNumber" To sDocNumber
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].SyncToken" To sSyncToken
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].domain" To sDomain
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].Balance" To sBalance
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].BillAddr.City" To sBillAddrCity
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].BillAddr.Line1" To sBillAddrLine1
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].BillAddr.PostalCode" To sBillAddrPostalCode
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].BillAddr.Lat" To sBillAddrLat
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].BillAddr.Long" To sBillAddrLong
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].BillAddr.CountrySubDivisionCode" To sBillAddrCountrySubDivisionCode
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].BillAddr.Id" To sBillAddrId
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].TxnDate" To sTxnDate
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].TotalAmt" To sTotalAmt
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].CustomerRef.name" To sCustomerRefName
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].CustomerRef.value" To sCustomerRefValue
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].ShipAddr.City" To sShipAddrCity
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].ShipAddr.Line1" To sShipAddrLine1
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].ShipAddr.PostalCode" To sShipAddrPostalCode
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].ShipAddr.Lat" To sShipAddrLat
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].ShipAddr.Long" To sShipAddrLong
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].ShipAddr.CountrySubDivisionCode" To sShipAddrCountrySubDivisionCode
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].ShipAddr.Id" To sShipAddrId
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].DueDate" To sDueDate
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].PrintStatus" To sPrintStatus
        Get ComIntOf Of hoJson "QueryResponse.Invoice[i].Deposit" To iDeposit
        Get ComBoolOf Of hoJson "QueryResponse.Invoice[i].sparse" To iSparse
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].EmailStatus" To sEmailStatus
        Get ComBoolOf Of hoJson "QueryResponse.Invoice[i].ApplyTaxAfterDiscount" To iApplyTaxAfterDiscount
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].Id" To sId
        Get ComIntOf Of hoJson "QueryResponse.Invoice[i].TxnTaxDetail.TotalTax" To iTxnTaxDetailTotalTax
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].MetaData.CreateTime" To sMetaDataCreateTime
        Get ComStringOf Of hoJson "QueryResponse.Invoice[i].MetaData.LastUpdatedTime" To sMetaDataLastUpdatedTime
        Move 0 To j
        Get ComSizeOfArray Of hoJson "QueryResponse.Invoice[i].LinkedTxn" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "QueryResponse.Invoice[i].Line" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComIntOf Of hoJson "QueryResponse.Invoice[i].Line[j].LineNum" To iLineNum
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].Line[j].Amount" To sAmount
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].Line[j].SalesItemLineDetail.TaxCodeRef.value" To sSalesItemLineDetailTaxCodeRefValue
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].Line[j].SalesItemLineDetail.ItemRef.name" To sSalesItemLineDetailItemRefName
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].Line[j].SalesItemLineDetail.ItemRef.value" To sSalesItemLineDetailItemRefValue
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].Line[j].Id" To sId
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].Line[j].DetailType" To sDetailType
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJson "QueryResponse.Invoice[i].CustomField" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].CustomField[j].DefinitionId" To sDefinitionId
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].CustomField[j].Type" To sInvType
            Get ComStringOf Of hoJson "QueryResponse.Invoice[i].CustomField[j].Name" To sName
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop



End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.