In this article, we will learn how to get invoices from Quickbooks online in .NET MVC web application using SDK.
Before using any Quickbooks online API we need access token, if you don’t know how to get access token then you can find it here.
public ActionResult GetAllInvoice() { List<Invoice> InvoiceList = new List<Invoice>(); try { OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(Access_token); // Create a ServiceContext with Auth tokens and realmId ServiceContext serviceContext = new ServiceContext(RealmId, IntuitServicesType.QBO, oauthValidator); serviceContext.IppConfiguration.MinorVersion.Qbo = "23"; serviceContext.IppConfiguration.BaseUrl.Qbo = QboBaseUrl; // Create a QuickBooks QueryService using ServiceContext QueryService<Invoice> querySvc = new QueryService<Invoice>(serviceContext); InvoiceList = querySvc.ExecuteIdsQuery("SELECT * FROM Invoice").ToList(); return View(InvoiceList); } catch (IdsException ex) { return View(InvoiceList); } catch (Exception ex) { return View(InvoiceList); } }
@model List<Intuit.Ipp.Data.Invoice> @{ ViewBag.Title = "GetAllInvoice"; } <h2>Quickbooks online Invoice List</h2> <div> <table class="table table-bordered"> <tr> <th>QBO ID</th> <th>Invoice Number</th> <th>Invoice Date</th> <th>Customer</th> <th>Total Amount</th> </tr> @foreach (var item in Model) { <tr> <td>@item.Id</td> <td>@item.DocNumber</td> <td>@item.TxnDate.ToString("MM/dd/yyyy")</td> <td>@item.CustomerRef.name</td> <td>@item.TotalAmt</td> </tr> } </table> </div>
string EXISTING_INVOICE_QUERYBYID = string.Format("select * from Invoice where id = '{0}'", "147"); Invoice objInvoiceFound = queryService.ExecuteIdsQuery(EXISTING_INVOICE_QUERYBYID).FirstOrDefault<Invoice>();
So that’s how we can get Invoices or query Invoices from Quickbooks online.
Output:
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular