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

PowerBuilder 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
Jira
Lightspeed
MYOB
Magento
Mailgun

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
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
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

 

 

 

(PowerBuilder) 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

integer li_rc
oleobject loo_JsonToken
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_Port
integer li_BAutoReconnect
integer li_Success
oleobject loo_SbAuth
oleobject loo_SbResponseBody
integer li_RespStatusCode
oleobject loo_Json
string ls_DocNumber
string ls_SyncToken
string ls_Domain
string ls_Balance
string ls_BillAddrCity
string ls_BillAddrLine1
string ls_BillAddrPostalCode
string ls_BillAddrLat
string ls_BillAddrLong
string ls_BillAddrCountrySubDivisionCode
string ls_BillAddrId
string ls_TxnDate
string ls_TotalAmt
string ls_CustomerRefName
string ls_CustomerRefValue
string ls_ShipAddrCity
string ls_ShipAddrLine1
string ls_ShipAddrPostalCode
string ls_ShipAddrLat
string ls_ShipAddrLong
string ls_ShipAddrCountrySubDivisionCode
string ls_ShipAddrId
string ls_DueDate
string ls_PrintStatus
integer li_Deposit
integer li_Sparse
string ls_EmailStatus
integer li_ApplyTaxAfterDiscount
string ls_Id
integer li_TxnTaxDetailTotalTax
string ls_MetaDataCreateTime
string ls_MetaDataLastUpdatedTime
integer j
integer li_Count_j
integer li_LineNum
string ls_Amount
string ls_SalesItemLineDetailTaxCodeRefValue
string ls_SalesItemLineDetailItemRefName
string ls_SalesItemLineDetailItemRefValue
string ls_DetailType
string ls_DefinitionId
string ls_InvType
string ls_Name
integer li_QueryResponseStartPosition
integer li_QueryResponseTotalCount
integer li_QueryResponseMaxResults
string ls_Time
integer i
integer li_Count_i

// 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.
loo_JsonToken = create oleobject
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat_9_5_0.JsonObject")
if li_rc < 0 then
    destroy loo_JsonToken
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_Success = loo_JsonToken.LoadFile("qa_data/tokens/qb-access-token.json")

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")

li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("sandbox-quickbooks.api.intuit.com",li_Port,li_BTls,li_BAutoReconnect)

loo_SbAuth = create oleobject
li_rc = loo_SbAuth.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_SbAuth.Append("Bearer ")
loo_SbAuth.Append(loo_JsonToken.StringOf("access_token"))
loo_Rest.Authorization = loo_SbAuth.GetAsString()

// --------------------------------------------------------------------------
// 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..
loo_Rest.RemoveHeader("Content-Type")

loo_Rest.AddHeader("Accept","application/json")
loo_Rest.AllowHeaderFolding = 0

// Add a SELECT statement 
loo_Rest.AddQueryParam("query","select * from Invoice where id = '239'")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/v3/company/<realmID>/invoice",loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_JsonToken
    destroy loo_Rest
    destroy loo_SbAuth
    destroy loo_SbResponseBody
    return
end if

li_RespStatusCode = loo_Rest.ResponseStatusCode
if li_RespStatusCode >= 400 then
    Write-Debug "Response Status Code = " + string(li_RespStatusCode)
    Write-Debug "Response Header:"
    Write-Debug loo_Rest.ResponseHeader
    Write-Debug "Response Body:"
    Write-Debug loo_SbResponseBody.GetAsString()
    destroy loo_JsonToken
    destroy loo_Rest
    destroy loo_SbAuth
    destroy loo_SbResponseBody
    return
end if

// Success is indicated by a 200 response status.
Write-Debug "response status code = " + string(li_RespStatusCode)

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Json.LoadSb(loo_SbResponseBody)
loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()

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

li_QueryResponseStartPosition = loo_Json.IntOf("QueryResponse.startPosition")
li_QueryResponseTotalCount = loo_Json.IntOf("QueryResponse.totalCount")
li_QueryResponseMaxResults = loo_Json.IntOf("QueryResponse.maxResults")
ls_Time = loo_Json.StringOf("time")
i = 0
li_Count_i = loo_Json.SizeOfArray("QueryResponse.Invoice")
do while i < li_Count_i
    loo_Json.I = i
    ls_DocNumber = loo_Json.StringOf("QueryResponse.Invoice[i].DocNumber")
    ls_SyncToken = loo_Json.StringOf("QueryResponse.Invoice[i].SyncToken")
    ls_Domain = loo_Json.StringOf("QueryResponse.Invoice[i].domain")
    ls_Balance = loo_Json.StringOf("QueryResponse.Invoice[i].Balance")
    ls_BillAddrCity = loo_Json.StringOf("QueryResponse.Invoice[i].BillAddr.City")
    ls_BillAddrLine1 = loo_Json.StringOf("QueryResponse.Invoice[i].BillAddr.Line1")
    ls_BillAddrPostalCode = loo_Json.StringOf("QueryResponse.Invoice[i].BillAddr.PostalCode")
    ls_BillAddrLat = loo_Json.StringOf("QueryResponse.Invoice[i].BillAddr.Lat")
    ls_BillAddrLong = loo_Json.StringOf("QueryResponse.Invoice[i].BillAddr.Long")
    ls_BillAddrCountrySubDivisionCode = loo_Json.StringOf("QueryResponse.Invoice[i].BillAddr.CountrySubDivisionCode")
    ls_BillAddrId = loo_Json.StringOf("QueryResponse.Invoice[i].BillAddr.Id")
    ls_TxnDate = loo_Json.StringOf("QueryResponse.Invoice[i].TxnDate")
    ls_TotalAmt = loo_Json.StringOf("QueryResponse.Invoice[i].TotalAmt")
    ls_CustomerRefName = loo_Json.StringOf("QueryResponse.Invoice[i].CustomerRef.name")
    ls_CustomerRefValue = loo_Json.StringOf("QueryResponse.Invoice[i].CustomerRef.value")
    ls_ShipAddrCity = loo_Json.StringOf("QueryResponse.Invoice[i].ShipAddr.City")
    ls_ShipAddrLine1 = loo_Json.StringOf("QueryResponse.Invoice[i].ShipAddr.Line1")
    ls_ShipAddrPostalCode = loo_Json.StringOf("QueryResponse.Invoice[i].ShipAddr.PostalCode")
    ls_ShipAddrLat = loo_Json.StringOf("QueryResponse.Invoice[i].ShipAddr.Lat")
    ls_ShipAddrLong = loo_Json.StringOf("QueryResponse.Invoice[i].ShipAddr.Long")
    ls_ShipAddrCountrySubDivisionCode = loo_Json.StringOf("QueryResponse.Invoice[i].ShipAddr.CountrySubDivisionCode")
    ls_ShipAddrId = loo_Json.StringOf("QueryResponse.Invoice[i].ShipAddr.Id")
    ls_DueDate = loo_Json.StringOf("QueryResponse.Invoice[i].DueDate")
    ls_PrintStatus = loo_Json.StringOf("QueryResponse.Invoice[i].PrintStatus")
    li_Deposit = loo_Json.IntOf("QueryResponse.Invoice[i].Deposit")
    li_Sparse = loo_Json.BoolOf("QueryResponse.Invoice[i].sparse")
    ls_EmailStatus = loo_Json.StringOf("QueryResponse.Invoice[i].EmailStatus")
    li_ApplyTaxAfterDiscount = loo_Json.BoolOf("QueryResponse.Invoice[i].ApplyTaxAfterDiscount")
    ls_Id = loo_Json.StringOf("QueryResponse.Invoice[i].Id")
    li_TxnTaxDetailTotalTax = loo_Json.IntOf("QueryResponse.Invoice[i].TxnTaxDetail.TotalTax")
    ls_MetaDataCreateTime = loo_Json.StringOf("QueryResponse.Invoice[i].MetaData.CreateTime")
    ls_MetaDataLastUpdatedTime = loo_Json.StringOf("QueryResponse.Invoice[i].MetaData.LastUpdatedTime")
    j = 0
    li_Count_j = loo_Json.SizeOfArray("QueryResponse.Invoice[i].LinkedTxn")
    do while j < li_Count_j
        loo_Json.J = j
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_Json.SizeOfArray("QueryResponse.Invoice[i].Line")
    do while j < li_Count_j
        loo_Json.J = j
        li_LineNum = loo_Json.IntOf("QueryResponse.Invoice[i].Line[j].LineNum")
        ls_Amount = loo_Json.StringOf("QueryResponse.Invoice[i].Line[j].Amount")
        ls_SalesItemLineDetailTaxCodeRefValue = loo_Json.StringOf("QueryResponse.Invoice[i].Line[j].SalesItemLineDetail.TaxCodeRef.value")
        ls_SalesItemLineDetailItemRefName = loo_Json.StringOf("QueryResponse.Invoice[i].Line[j].SalesItemLineDetail.ItemRef.name")
        ls_SalesItemLineDetailItemRefValue = loo_Json.StringOf("QueryResponse.Invoice[i].Line[j].SalesItemLineDetail.ItemRef.value")
        ls_Id = loo_Json.StringOf("QueryResponse.Invoice[i].Line[j].Id")
        ls_DetailType = loo_Json.StringOf("QueryResponse.Invoice[i].Line[j].DetailType")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_Json.SizeOfArray("QueryResponse.Invoice[i].CustomField")
    do while j < li_Count_j
        loo_Json.J = j
        ls_DefinitionId = loo_Json.StringOf("QueryResponse.Invoice[i].CustomField[j].DefinitionId")
        ls_InvType = loo_Json.StringOf("QueryResponse.Invoice[i].CustomField[j].Type")
        ls_Name = loo_Json.StringOf("QueryResponse.Invoice[i].CustomField[j].Name")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_JsonToken
destroy loo_Rest
destroy loo_SbAuth
destroy loo_SbResponseBody
destroy loo_Json

 

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