In this article, we will learn how to get a category 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 GetAllCategory() { List<Item> ItemList = new List<Item>(); 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<Item> querySvc = new QueryService<Item>(serviceContext); ItemList = querySvc.ExecuteIdsQuery("select * from Item where Type='Category'").ToList(); return View(ItemList); } catch (IdsException ex) { return View(ItemList); } catch (Exception ex) { return View(ItemList); } }
@model List<Intuit.Ipp.Data.Item> @{ ViewBag.Title = "GetAllCategory"; } <h2>GetAllCategory</h2> <div> <table class="table table-bordered"> <tr> <th>QBO ID</th> <th>Category Name</th> </tr> @foreach (var item in Model) { <tr> <td>@item.Id</td> <td>@item.Name</td> </tr> } </table> </div>
string EXISTING_CATEGORY_QUERYBYNAME = string.Format("select * from Item where Name = '{0}' and Type='{1}'", "Electronics", "Category"); Item objItemFound = querySvc.ExecuteIdsQuery(EXISTING_CATEGORY_QUERYBYNAME).FirstOrDefault<Item>();
So that’s how we can get Categories or query Categories 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