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

 

 

 

(DataFlex) Quickbooks Delete an Invoice

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

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

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoJsonToken
    Boolean iSuccess
    Handle hoRest
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    Boolean iSuccess
    Handle hoSbAuth
    Handle hoJsonReq
    Variant vSbRequestBody
    Handle hoSbRequestBody
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJsonResponse
    String sInvoiceStatus
    String sInvoiceDomain
    String sInvoiceId
    String sTime
    String sTemp1
    Integer iTemp1

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

    // Connect to the REST server.
    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 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.
    // --------------------------------------------------------------------------

    // Create the following JSON:

    // {
    //   "SyncToken": "3",
    //   "Id": "33"
    // }
    // 
    // Use the this online tool to generate the code from sample JSON: 
    // Generate Code to Create JSON

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonReq
    If (Not(IsComObjectCreated(hoJsonReq))) Begin
        Send CreateComObject of hoJsonReq
    End
    Get ComUpdateString Of hoJsonReq "SyncToken" "3" To iSuccess
    Get ComUpdateString Of hoJsonReq "Id" "33" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
    If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
        Send CreateComObject of hoSbRequestBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get ComEmitSb Of hoJsonReq vSbRequestBody To iSuccess

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

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbRequestBody to vSbRequestBody
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestSb Of hoRest "POST" "/v3/company/<realmID>/invoice?operation=delete" vSbRequestBody vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode

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

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

    Get ComResponseStatusCode Of hoRest To iTemp1
    If (iTemp1 <> 200) Begin
        Showln "Failed."
        Procedure_Return
    End

    // 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": {
    //     "status": "Deleted",
    //     "domain": "QBO",
    //     "Id": "33"
    //   },
    //   "time": "2013-03-15T00:18:15.322-07:00"
    // }
    // 

    Get ComStringOf Of hoJsonResponse "Invoice.status" To sInvoiceStatus
    Get ComStringOf Of hoJsonResponse "Invoice.domain" To sInvoiceDomain
    Get ComStringOf Of hoJsonResponse "Invoice.Id" To sInvoiceId
    Get ComStringOf Of hoJsonResponse "time" To sTime


End_Procedure

 

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