Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

VB.NET UWP/WinRT Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Bitfinex v2 REST
Bluzone
BrickLink
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
Mastercard

MedTunnel
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
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
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(VB.NET UWP/WinRT) Quickbooks Send an Invoice

Demonstrates how to send 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#send-an-invoice

Chilkat Universal Windows Platform (UWP) / WinRT Downloads

Chilkat for the Universal Windows Platform (UWP)

' 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.
Dim jsonToken As New Chilkat.JsonObject
Dim success As Boolean = jsonToken.LoadFile("qa_data/tokens/qb-access-token.json")

Dim rest As New Chilkat.Rest

' Connect to the REST server.
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
Dim success As Boolean = Await rest.ConnectAsync("sandbox-quickbooks.api.intuit.com",port,bTls,bAutoReconnect)

Dim sbAuth As New Chilkat.StringBuilder
sbAuth.Append("Bearer ")
sbAuth.Append(jsonToken.StringOf("access_token"))
rest.Authorization = sbAuth.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.
' --------------------------------------------------------------------------

' Technically, the POST has an empty request body, but the Quickbooks documentation indicates that 
' the Content-Type header should be set to "application/octet-stream", which really makes no sense
' because there is not content. (How can no content have a type???)
rest.AddHeader("Content-Type","application/octet-stream")
rest.AllowHeaderFolding = False

Dim sbResponseBody As New Chilkat.StringBuilder
success = Await rest.FullRequestNoBodySbAsync("POST","/v3/company/<realmID>/invoice/<invoiceId>/send?sendTo=<emailAddr>",sbResponseBody)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


Dim respStatusCode As Integer = rest.ResponseStatusCode

' Success is indicated by a 200 response status code.
Debug.WriteLine("response status code = " & respStatusCode)

Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.LoadSb(sbResponseBody)
jsonResponse.EmitCompact = False
Debug.WriteLine(jsonResponse.Emit())

If (rest.ResponseStatusCode <> 200) Then
    Debug.WriteLine("Failed.")
    Exit Sub
End If


' 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": {
'     "TxnDate": "2013-03-14",
'     "domain": "QBO",
'     "CurrencyRef": {
'       "name": "United States Dollar",
'       "value": "USD"
'     },
'     "ShipDate": "2013-03-01",
'     "TrackingNum": "123456789",
'     "ClassRef": {
'       "name": "Class 1",
'       "value": "200900000000000003901"
'     },
'     "PrintStatus": "NeedToPrint",
'     "SalesTermRef": {
'       "value": "4"
'     },
'     "DeliveryInfo": {
'       "DeliveryType": "Email",
'       "DeliveryTime": "2014-12-17T11:50:52-08:00"
'     },
'     "TotalAmt": 52.0,
'     "Line": [
'       {
'         "Description": "Sample invoice create request",
'         "DetailType": "SalesItemLineDetail",
'         "SalesItemLineDetail": {
'           "TaxCodeRef": {
'             "value": "TAX"
'           },
'           "Qty": 1,
'           "UnitPrice": 50,
'           "ServiceDate": "2013-03-04",
'           "ItemRef": {
'             "name": "Hours",
'             "value": "2"
'           }
'         },
'         "LineNum": 1,
'         "Amount": 50.0,
'         "Id": "1"
'       },
'       {
'         "DetailType": "SubTotalLineDetail",
'         "Amount": 50.0,
'         "SubTotalLineDetail": {}
'       },
'       {
'         "DetailType": "DiscountLineDetail",
'         "Amount": 5.0,
'         "DiscountLineDetail": {
'           "DiscountAccountRef": {
'             "name": "Discounts given",
'             "value": "30"
'           },
'           "PercentBased": true,
'           "DiscountPercent": 10
'         }
'       },
'       {
'         "DetailType": "SalesItemLineDetail",
'         "Amount": 2.0,
'         "SalesItemLineDetail": {
'           "ItemRef": {
'             "value": "SHIPPING_ITEM_ID"
'           }
'         }
'       }
'     ],
'     "DueDate": "2013-05-13",
'     "MetaData": {
'       "CreateTime": "2013-03-14T01:42:16-07:00",
'       "LastUpdatedTime": "2014-12-17T11:50:58-08:00"
'     },
'     "DocNumber": "Sample_Inv#2",
'     "PrivateNote": "Summary for sample invoice",
'     "sparse": false,
'     "DepositToAccountRef": {
'       "name": "Undeposited Funds",
'       "value": "4"
'     },
'     "CustomerMemo": {
'       "value": "This is the customer message"
'     },
'     "EmailStatus": "EmailSent",
'     "Deposit": 12.0,
'     "Balance": 40.0,
'     "CustomerRef": {
'       "name": "Mr V3 Service Customer Jr2",
'       "value": "15"
'     },
'     "TxnTaxDetail": {
'       "TxnTaxCodeRef": {
'         "value": "5"
'       },
'       "TotalTax": 5.0,
'       "TaxLine": [
'         {
'           "DetailType": "TaxLineDetail",
'           "Amount": 5.0,
'           "TaxLineDetail": {
'             "NetAmountTaxable": 50.0,
'             "TaxPercent": 10,
'             "TaxRateRef": {
'               "value": "2"
'             },
'             "PercentBased": true
'           }
'         }
'       ]
'     },
'     "SyncToken": "0",
'     "BillEmail": {
'       "Address": "test@intuit.com"
'     },
'     "ShipAddr": {
'       "City": "San Jose",
'       "Country": "USA",
'       "Line5": "Cube 999",
'       "Line4": "Dept 12",
'       "Line3": "123 street",
'       "Line2": "Building 1",
'       "Line1": "Intuit",
'       "PostalCode": "95123",
'       "Lat": "37.2374847",
'       "Long": "-121.8277925",
'       "CountrySubDivisionCode": "CA",
'       "Id": "36"
'     },
'     "DepartmentRef": {
'       "name": "Mountain View",
'       "value": "1"
'     },
'     "ShipMethodRef": {
'       "name": "UPS",
'       "value": "UPS"
'     },
'     "BillAddr": {
'       "City": "Mountain View",
'       "Country": "USA",
'       "Line5": "Cube 999",
'       "Line4": "Dept 12",
'       "Line3": "123 street",
'       "Line2": "Building 1",
'       "Line1": "Google",
'       "PostalCode": "95123",
'       "Lat": "37.2374847",
'       "Long": "-121.8277925",
'       "CountrySubDivisionCode": "CA",
'       "Id": "35"
'     },
'     "ApplyTaxAfterDiscount": false,
'     "CustomField": [
'       {
'         "StringValue": "Custom1",
'         "Type": "StringType",
'         "Name": "Custom 1"
'       },
'       {
'         "StringValue": "Custom2",
'         "Type": "StringType",
'         "Name": "Custom 2"
'       },
'       {
'         "StringValue": "Custom3",
'         "Type": "StringType",
'         "Name": "Custom 3"
'       }
'     ],
'     "Id": "96"
'   },
'   "time": "2013-03-14T13:32:04.895-07:00"
' }
' 



Dim Description As String
Dim DetailType As String
Dim SalesItemLineDetailTaxCodeRefValue As String
Dim SalesItemLineDetailQty As Integer
Dim SalesItemLineDetailUnitPrice As Integer
Dim SalesItemLineDetailServiceDate As String
Dim SalesItemLineDetailItemRefName As String
Dim SalesItemLineDetailItemRefValue As String
Dim LineNum As Integer
Dim Amount As String
Dim Id As String
Dim DiscountLineDetailDiscountAccountRefName As String
Dim DiscountLineDetailDiscountAccountRefValue As String
Dim DiscountLineDetailPercentBased As Boolean
Dim DiscountLineDetailDiscountPercent As Integer
Dim TaxLineDetailNetAmountTaxable As String
Dim TaxLineDetailTaxPercent As Integer
Dim TaxLineDetailTaxRateRefValue As String
Dim TaxLineDetailPercentBased As Boolean
Dim StringValue As String
Dim Type As String
Dim Name As String

Dim InvoiceTxnDate As String = jsonResponse.StringOf("Invoice.TxnDate")
Dim InvoiceDomain As String = jsonResponse.StringOf("Invoice.domain")
Dim InvoiceCurrencyRefName As String = jsonResponse.StringOf("Invoice.CurrencyRef.name")
Dim InvoiceCurrencyRefValue As String = jsonResponse.StringOf("Invoice.CurrencyRef.value")
Dim InvoiceShipDate As String = jsonResponse.StringOf("Invoice.ShipDate")
Dim InvoiceTrackingNum As String = jsonResponse.StringOf("Invoice.TrackingNum")
Dim InvoiceClassRefName As String = jsonResponse.StringOf("Invoice.ClassRef.name")
Dim InvoiceClassRefValue As String = jsonResponse.StringOf("Invoice.ClassRef.value")
Dim InvoicePrintStatus As String = jsonResponse.StringOf("Invoice.PrintStatus")
Dim InvoiceSalesTermRefValue As String = jsonResponse.StringOf("Invoice.SalesTermRef.value")
Dim InvoiceDeliveryInfoDeliveryType As String = jsonResponse.StringOf("Invoice.DeliveryInfo.DeliveryType")
Dim InvoiceDeliveryInfoDeliveryTime As String = jsonResponse.StringOf("Invoice.DeliveryInfo.DeliveryTime")
Dim InvoiceTotalAmt As String = jsonResponse.StringOf("Invoice.TotalAmt")
Dim InvoiceDueDate As String = jsonResponse.StringOf("Invoice.DueDate")
Dim InvoiceMetaDataCreateTime As String = jsonResponse.StringOf("Invoice.MetaData.CreateTime")
Dim InvoiceMetaDataLastUpdatedTime As String = jsonResponse.StringOf("Invoice.MetaData.LastUpdatedTime")
Dim InvoiceDocNumber As String = jsonResponse.StringOf("Invoice.DocNumber")
Dim InvoicePrivateNote As String = jsonResponse.StringOf("Invoice.PrivateNote")
Dim InvoiceSparse As Boolean = jsonResponse.BoolOf("Invoice.sparse")
Dim InvoiceDepositToAccountRefName As String = jsonResponse.StringOf("Invoice.DepositToAccountRef.name")
Dim InvoiceDepositToAccountRefValue As String = jsonResponse.StringOf("Invoice.DepositToAccountRef.value")
Dim InvoiceCustomerMemoValue As String = jsonResponse.StringOf("Invoice.CustomerMemo.value")
Dim InvoiceEmailStatus As String = jsonResponse.StringOf("Invoice.EmailStatus")
Dim InvoiceDeposit As String = jsonResponse.StringOf("Invoice.Deposit")
Dim InvoiceBalance As String = jsonResponse.StringOf("Invoice.Balance")
Dim InvoiceCustomerRefName As String = jsonResponse.StringOf("Invoice.CustomerRef.name")
Dim InvoiceCustomerRefValue As String = jsonResponse.StringOf("Invoice.CustomerRef.value")
Dim InvoiceTxnTaxDetailTxnTaxCodeRefValue As String = jsonResponse.StringOf("Invoice.TxnTaxDetail.TxnTaxCodeRef.value")
Dim InvoiceTxnTaxDetailTotalTax As String = jsonResponse.StringOf("Invoice.TxnTaxDetail.TotalTax")
Dim InvoiceSyncToken As String = jsonResponse.StringOf("Invoice.SyncToken")
Dim InvoiceBillEmailAddress As String = jsonResponse.StringOf("Invoice.BillEmail.Address")
Dim InvoiceShipAddrCity As String = jsonResponse.StringOf("Invoice.ShipAddr.City")
Dim InvoiceShipAddrCountry As String = jsonResponse.StringOf("Invoice.ShipAddr.Country")
Dim InvoiceShipAddrLine5 As String = jsonResponse.StringOf("Invoice.ShipAddr.Line5")
Dim InvoiceShipAddrLine4 As String = jsonResponse.StringOf("Invoice.ShipAddr.Line4")
Dim InvoiceShipAddrLine3 As String = jsonResponse.StringOf("Invoice.ShipAddr.Line3")
Dim InvoiceShipAddrLine2 As String = jsonResponse.StringOf("Invoice.ShipAddr.Line2")
Dim InvoiceShipAddrLine1 As String = jsonResponse.StringOf("Invoice.ShipAddr.Line1")
Dim InvoiceShipAddrPostalCode As String = jsonResponse.StringOf("Invoice.ShipAddr.PostalCode")
Dim InvoiceShipAddrLat As String = jsonResponse.StringOf("Invoice.ShipAddr.Lat")
Dim InvoiceShipAddrLong As String = jsonResponse.StringOf("Invoice.ShipAddr.Long")
Dim InvoiceShipAddrCountrySubDivisionCode As String = jsonResponse.StringOf("Invoice.ShipAddr.CountrySubDivisionCode")
Dim InvoiceShipAddrId As String = jsonResponse.StringOf("Invoice.ShipAddr.Id")
Dim InvoiceDepartmentRefName As String = jsonResponse.StringOf("Invoice.DepartmentRef.name")
Dim InvoiceDepartmentRefValue As String = jsonResponse.StringOf("Invoice.DepartmentRef.value")
Dim InvoiceShipMethodRefName As String = jsonResponse.StringOf("Invoice.ShipMethodRef.name")
Dim InvoiceShipMethodRefValue As String = jsonResponse.StringOf("Invoice.ShipMethodRef.value")
Dim InvoiceBillAddrCity As String = jsonResponse.StringOf("Invoice.BillAddr.City")
Dim InvoiceBillAddrCountry As String = jsonResponse.StringOf("Invoice.BillAddr.Country")
Dim InvoiceBillAddrLine5 As String = jsonResponse.StringOf("Invoice.BillAddr.Line5")
Dim InvoiceBillAddrLine4 As String = jsonResponse.StringOf("Invoice.BillAddr.Line4")
Dim InvoiceBillAddrLine3 As String = jsonResponse.StringOf("Invoice.BillAddr.Line3")
Dim InvoiceBillAddrLine2 As String = jsonResponse.StringOf("Invoice.BillAddr.Line2")
Dim InvoiceBillAddrLine1 As String = jsonResponse.StringOf("Invoice.BillAddr.Line1")
Dim InvoiceBillAddrPostalCode As String = jsonResponse.StringOf("Invoice.BillAddr.PostalCode")
Dim InvoiceBillAddrLat As String = jsonResponse.StringOf("Invoice.BillAddr.Lat")
Dim InvoiceBillAddrLong As String = jsonResponse.StringOf("Invoice.BillAddr.Long")
Dim InvoiceBillAddrCountrySubDivisionCode As String = jsonResponse.StringOf("Invoice.BillAddr.CountrySubDivisionCode")
Dim InvoiceBillAddrId As String = jsonResponse.StringOf("Invoice.BillAddr.Id")
Dim InvoiceApplyTaxAfterDiscount As Boolean = jsonResponse.BoolOf("Invoice.ApplyTaxAfterDiscount")
Dim InvoiceId As String = jsonResponse.StringOf("Invoice.Id")
Dim time As String = jsonResponse.StringOf("time")
Dim i As Integer = 0
Dim count_i As Integer = jsonResponse.SizeOfArray("Invoice.Line")
While i < count_i
    jsonResponse.I = i
    Description = jsonResponse.StringOf("Invoice.Line[i].Description")
    DetailType = jsonResponse.StringOf("Invoice.Line[i].DetailType")
    SalesItemLineDetailTaxCodeRefValue = jsonResponse.StringOf("Invoice.Line[i].SalesItemLineDetail.TaxCodeRef.value")
    SalesItemLineDetailQty = jsonResponse.IntOf("Invoice.Line[i].SalesItemLineDetail.Qty")
    SalesItemLineDetailUnitPrice = jsonResponse.IntOf("Invoice.Line[i].SalesItemLineDetail.UnitPrice")
    SalesItemLineDetailServiceDate = jsonResponse.StringOf("Invoice.Line[i].SalesItemLineDetail.ServiceDate")
    SalesItemLineDetailItemRefName = jsonResponse.StringOf("Invoice.Line[i].SalesItemLineDetail.ItemRef.name")
    SalesItemLineDetailItemRefValue = jsonResponse.StringOf("Invoice.Line[i].SalesItemLineDetail.ItemRef.value")
    LineNum = jsonResponse.IntOf("Invoice.Line[i].LineNum")
    Amount = jsonResponse.StringOf("Invoice.Line[i].Amount")
    Id = jsonResponse.StringOf("Invoice.Line[i].Id")
    DiscountLineDetailDiscountAccountRefName = jsonResponse.StringOf("Invoice.Line[i].DiscountLineDetail.DiscountAccountRef.name")
    DiscountLineDetailDiscountAccountRefValue = jsonResponse.StringOf("Invoice.Line[i].DiscountLineDetail.DiscountAccountRef.value")
    DiscountLineDetailPercentBased = jsonResponse.BoolOf("Invoice.Line[i].DiscountLineDetail.PercentBased")
    DiscountLineDetailDiscountPercent = jsonResponse.IntOf("Invoice.Line[i].DiscountLineDetail.DiscountPercent")
    i = i + 1
End While
i = 0
count_i = jsonResponse.SizeOfArray("Invoice.TxnTaxDetail.TaxLine")
While i < count_i
    jsonResponse.I = i
    DetailType = jsonResponse.StringOf("Invoice.TxnTaxDetail.TaxLine[i].DetailType")
    Amount = jsonResponse.StringOf("Invoice.TxnTaxDetail.TaxLine[i].Amount")
    TaxLineDetailNetAmountTaxable = jsonResponse.StringOf("Invoice.TxnTaxDetail.TaxLine[i].TaxLineDetail.NetAmountTaxable")
    TaxLineDetailTaxPercent = jsonResponse.IntOf("Invoice.TxnTaxDetail.TaxLine[i].TaxLineDetail.TaxPercent")
    TaxLineDetailTaxRateRefValue = jsonResponse.StringOf("Invoice.TxnTaxDetail.TaxLine[i].TaxLineDetail.TaxRateRef.value")
    TaxLineDetailPercentBased = jsonResponse.BoolOf("Invoice.TxnTaxDetail.TaxLine[i].TaxLineDetail.PercentBased")
    i = i + 1
End While
i = 0
count_i = jsonResponse.SizeOfArray("Invoice.CustomField")
While i < count_i
    jsonResponse.I = i
    StringValue = jsonResponse.StringOf("Invoice.CustomField[i].StringValue")
    Type = jsonResponse.StringOf("Invoice.CustomField[i].Type")
    Name = jsonResponse.StringOf("Invoice.CustomField[i].Name")
    i = i + 1
End While

 

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