In this article, we will learn how to get customers 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 GetCustomer() { List<Customer> CustomerList = new List<Customer>(); 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<Customer> querySvc = new QueryService<Customer>(serviceContext); CustomerList = querySvc.ExecuteIdsQuery("SELECT * FROM Customer").ToList(); return View(CustomerList); } catch (IdsException ex) { return View(CustomerList); } catch (Exception ex) { return View(CustomerList); } }
@model List<Intuit.Ipp.Data.Customer> @{ ViewBag.Title = "GetCustomer"; } <h2>Quickbooks online Customer List</h2> <div> <table class="table table-bordered"> <tr> <th>QBO ID</th> <th>Display Name</th> <th>Given Name</th> <th>Family Name</th> <th>Email</th> <th>Primary Phone</th> </tr> @foreach (var Cust in Model) { <tr> <td>@Cust.Id</td> <td>@Cust.DisplayName</td> <td>@Cust.GivenName</td> <td>@Cust.FamilyName</td> @if (Cust.PrimaryEmailAddr != null && !string.IsNullOrEmpty(Cust.PrimaryEmailAddr.Address)) { <td>@Cust.PrimaryEmailAddr.Address</td> } else { <td></td> } @if (Cust.PrimaryPhone != null && !string.IsNullOrEmpty(Cust.PrimaryPhone.FreeFormNumber)) { <td>@Cust.PrimaryPhone.FreeFormNumber</td> } else { <td></td> } </tr> } </table> </div>
string EXISTING_CUSTOMER_QUERYBYID = string.Format("select * from customer where DisplayName = '{0}'", "Tabish Rangrej"); Customer objCustomerFound = queryService.ExecuteIdsQuery(EXISTING_CUSTOMER_QUERYBYID).FirstOrDefault<Customer>();
So that’s how we can get customers or query customers 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