In this article, we will learn how to get employees 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 GetAllEmployee() { List<Employee> EmployeeList = new List<Employee>(); 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<Employee> querySvc = new QueryService<Employee>(serviceContext); EmployeeList = querySvc.ExecuteIdsQuery("SELECT * FROM Employee").ToList(); return View(EmployeeList); } catch (IdsException ex) { return View(EmployeeList); } catch (Exception ex) { return View(EmployeeList); } }
@model List<Intuit.Ipp.Data.Employee> @{ ViewBag.Title = "GetAllEmployee"; } <h2>Quickbooks online Employee 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 Emp in Model) { <tr> <td>@Emp.Id</td> <td>@Emp.DisplayName</td> <td>@Emp.GivenName</td> <td>@Emp.FamilyName</td> @if (Emp.PrimaryEmailAddr != null && !string.IsNullOrEmpty(Emp.PrimaryEmailAddr.Address)) { <td>@Emp.PrimaryEmailAddr.Address</td> } else { <td></td> } @if (Emp.PrimaryPhone != null && !string.IsNullOrEmpty(Emp.PrimaryPhone.FreeFormNumber)) { <td>@Emp.PrimaryPhone.FreeFormNumber</td> } else { <td></td> } </tr> } </table> </div>
string EXISTING_EMPLOYEE_QUERYBYID = string.Format("select * from Employee where DisplayName = '{0}'", "Tabish Employee"); Employee objEmployeeFound = queryService.ExecuteIdsQuery(EXISTING_EMPLOYEE_QUERYBYID).FirstOrDefault<Employee>();
So that’s how we can get employees or query employees 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