In this article, we will learn how to get accounts 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 GetAllAccount() { List<Account> AccountList = new List<Account>(); 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<Account> querySvc = new QueryService<Account>(serviceContext); AccountList = querySvc.ExecuteIdsQuery("SELECT * FROM Account").ToList(); return View(AccountList); } catch (IdsException ex) { return View(AccountList); } catch (Exception ex) { return View(AccountList); } }
@model List<Intuit.Ipp.Data.Account> @{ ViewBag.Title = "GetAllAccount"; } <h2>Quickbooks online Account List</h2> <div> <table class="table table-bordered"> <tr> <th>QBO ID</th> <th>Account Name</th> <th>Account Type</th> <th>Account Fully Qualified Name</th> </tr> @foreach (var Acct in Model) { <tr> <td>@Acct.Id</td> <td>@Acct.Name</td> <td>@Acct.AccountType</td> <td>@Acct.FullyQualifiedName</td> </tr> } </table> </div>
string EXISTING_ACCOUNT_QUERYBYNAME = string.Format("select * from Account where Name = '{0}'", "Tabish Income Account"); Account objAccountFound = querySvc.ExecuteIdsQuery(EXISTING_ACCOUNT_QUERYBYNAME).FirstOrDefault<Account>();
So that’s how we can get accounts or query accounts 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