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
(DataFlex) QuickBooks - Create an AccountDemonstrates how to send an JSON request to create a QuickBooks account. For more information, see https://developer.intuit.com/app/developer/qbo/docs/api/accounting/ecommerce/account#create-an-account
Use ChilkatAx-win32.pkg Procedure Test Handle hoJsonToken Boolean iSuccess Handle hoRest Boolean iBAutoReconnect Handle hoSbAuth Handle hoJsonRequest String sRequestBody Handle hoSbPath String sResponseBody Handle hoJsonResponse String sTemp1 Integer iTemp1 Boolean bTemp1 // This example assumes 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 iBAutoReconnect Get ComConnect Of hoRest "sandbox-quickbooks.api.intuit.com" 443 True iBAutoReconnect To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End 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 Get Create (RefClass(cComChilkatJsonObject)) To hoJsonRequest If (Not(IsComObjectCreated(hoJsonRequest))) Begin Send CreateComObject of hoJsonRequest End Get ComAppendString Of hoJsonRequest "AccountType" "Credit Card" To iSuccess Get ComAppendString Of hoJsonRequest "Name" "Banana Republic" To iSuccess Get ComEmit Of hoJsonRequest To sRequestBody // "123146096291789" is the company ID. Get Create (RefClass(cComChilkatStringBuilder)) To hoSbPath If (Not(IsComObjectCreated(hoSbPath))) Begin Send CreateComObject of hoSbPath End Get ComAppend Of hoSbPath "/v3/company/123146096291789/account?minorversion=45" 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 ComGetAsString Of hoSbPath To sTemp1 Get ComFullRequestString Of hoRest "POST" sTemp1 sRequestBody To sResponseBody Get ComLastMethodSuccess Of hoRest To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoRest To sTemp1 Showln sTemp1 Procedure_Return End // We should expect a 200 response if successful. Get ComResponseStatusCode Of hoRest To iTemp1 If (iTemp1 <> 200) Begin Showln "Request Header: " Get ComLastRequestHeader Of hoRest To sTemp1 Showln sTemp1 Showln "----" Get ComResponseStatusCode Of hoRest To iTemp1 Showln "Response StatusCode = " iTemp1 Get ComResponseStatusText Of hoRest To sTemp1 Showln "Response StatusLine: " sTemp1 Showln "Response Header:" Get ComResponseHeader Of hoRest To sTemp1 Showln sTemp1 Showln sResponseBody Procedure_Return End Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse If (Not(IsComObjectCreated(hoJsonResponse))) Begin Send CreateComObject of hoJsonResponse End Get ComLoad Of hoJsonResponse sResponseBody To iSuccess Set ComEmitCompact Of hoJsonResponse To False Get ComEmit Of hoJsonResponse To sTemp1 Showln sTemp1 Showln "Success." // A sample JSON response: // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // { // "Account": { // "Name": "Banana Republic", // "SubAccount": false, // "FullyQualifiedName": "Banana Republic", // "Active": true, // "Classification": "Liability", // "AccountType": "Credit Card", // "AccountSubType": "CreditCard", // "CurrentBalance": 0, // "CurrentBalanceWithSubAccounts": 0, // "CurrencyRef": { // "value": "USD", // "name": "United States Dollar" // }, // "domain": "QBO", // "sparse": false, // "Id": "97", // "SyncToken": "0", // "MetaData": { // "CreateTime": "2016-10-25T05:07:12-07:00", // "LastUpdatedTime": "2016-10-25T05:07:12-07:00" // } // }, // "time": "2016-10-25T05:07:11.714-07:00" // } End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.