Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Quickbooks Delete an InvoiceDemonstrates 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
LOCAL loJsonToken LOCAL lnSuccess LOCAL loRest LOCAL lnBTls LOCAL lnPort LOCAL lnBAutoReconnect LOCAL lnSuccess LOCAL loSbAuth LOCAL loJsonReq LOCAL loSbRequestBody LOCAL loSbResponseBody LOCAL lnRespStatusCode LOCAL loJsonResponse LOCAL lcInvoiceStatus LOCAL lcInvoiceDomain LOCAL lcInvoiceId LOCAL lcTime * 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. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJsonToken = CreateObject('Chilkat.JsonObject') lnSuccess = loJsonToken.LoadFile("qa_data/tokens/qb-access-token.json") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Rest') loRest = CreateObject('Chilkat.Rest') * Connect to the REST server. lnBTls = 1 lnPort = 443 lnBAutoReconnect = 1 lnSuccess = loRest.Connect("sandbox-quickbooks.api.intuit.com",lnPort,lnBTls,lnBAutoReconnect) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbAuth = CreateObject('Chilkat.StringBuilder') loSbAuth.Append("Bearer ") loSbAuth.Append(loJsonToken.StringOf("access_token")) loRest.Authorization = loSbAuth.GetAsString() * -------------------------------------------------------------------------- * 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 * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJsonReq = CreateObject('Chilkat.JsonObject') loJsonReq.UpdateString("SyncToken","3") loJsonReq.UpdateString("Id","33") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbRequestBody = CreateObject('Chilkat.StringBuilder') loJsonReq.EmitSb(loSbRequestBody) loRest.AddHeader("Content-Type","application/json") loRest.AddHeader("Accept","application/json") loRest.AllowHeaderFolding = 0 * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') lnSuccess = loRest.FullRequestSb("POST","/v3/company/<realmID>/invoice?operation=delete",loSbRequestBody,loSbResponseBody) IF (lnSuccess <> 1) THEN ? loRest.LastErrorText RELEASE loJsonToken RELEASE loRest RELEASE loSbAuth RELEASE loJsonReq RELEASE loSbRequestBody RELEASE loSbResponseBody CANCEL ENDIF lnRespStatusCode = loRest.ResponseStatusCode * Success is indicated by a 200 response status code. ? "response status code = " + STR(lnRespStatusCode) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJsonResponse = CreateObject('Chilkat.JsonObject') loJsonResponse.LoadSb(loSbResponseBody) loJsonResponse.EmitCompact = 0 ? loJsonResponse.Emit() IF (loRest.ResponseStatusCode <> 200) THEN ? "Failed." RELEASE loJsonToken RELEASE loRest RELEASE loSbAuth RELEASE loJsonReq RELEASE loSbRequestBody RELEASE loSbResponseBody RELEASE loJsonResponse CANCEL ENDIF * 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" * } * lcInvoiceStatus = loJsonResponse.StringOf("Invoice.status") lcInvoiceDomain = loJsonResponse.StringOf("Invoice.domain") lcInvoiceId = loJsonResponse.StringOf("Invoice.Id") lcTime = loJsonResponse.StringOf("time") RELEASE loJsonToken RELEASE loRest RELEASE loSbAuth RELEASE loJsonReq RELEASE loSbRequestBody RELEASE loSbResponseBody RELEASE loJsonResponse |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.