QuickBooks Online

Vendor Management In QuickBooks Online Using C#

In this article, I explain how to add vendor, get vendor and update vendor using the QuickBooks API v3 in c#.

SAMPLE OBJECT

{
  "Vendor": {
    "PrimaryEmailAddr": {
      "Address": "Books@Intuit.com"
    }, 
    "Vendor1099": false, 
    "domain": "QBO", 
    "GivenName": "Bessie", 
    "DisplayName": "Books by Bessie", 
    "BillAddr": {
      "City": "Palo Alto", 
      "Line1": "15 Main St.", 
      "PostalCode": "94303", 
      "Lat": "37.445013", 
      "Long": "-122.1391443", 
      "CountrySubDivisionCode": "CA", 
      "Id": "31"
    }, 
    "SyncToken": "0", 
    "PrintOnCheckName": "Books by Bessie", 
    "FamilyName": "Williams", 
    "PrimaryPhone": {
      "FreeFormNumber": "(650) 555-7745"
    }, 
    "AcctNum": "1345", 
    "CompanyName": "Books by Bessie", 
    "WebAddr": {
      "URI": "http://www.booksbybessie.co"
    }, 
    "sparse": false, 
    "Active": true, 
    "Balance": 0, 
    "Id": "30", 
    "MetaData": {
      "CreateTime": "2014-09-12T10:07:56-07:00", 
      "LastUpdatedTime": "2014-09-17T11:13:46-07:00"
    }
  }, 
  "time": "2015-07-28T13:33:09.453-07:00"
}

 

Add Vendor

Request Body

The minimum elements to create a vendor are listed here.

{
  "PrimaryEmailAddr": {
    "Address": "bhavdip.vision@gmail.com"
  }, 
  "WebAddr": {
    "URI": "http://www.bhavdiptalaviya.com"
  }, 
  "PrimaryPhone": {
    "FreeFormNumber": "(650) 555-2342"
  }, 
  "DisplayName": "bhavdip's Auto Shop", 
  "Suffix": "Sr.", 
  "Title": "Ms.", 
  "Mobile": {
    "FreeFormNumber": "(650) 555-2000"
  }, 
  "FamilyName": "Talaviya", 
  "TaxIdentifier": "99-5688293", 
  "AcctNum": "35372649", 
  "CompanyName": "bhavdip's Auto Shop", 
  "BillAddr": {
    "City": "Millbrae", 
    "Country": "U.S.A", 
    "Line1": "29834 Mustang Ave.", 
    "PostalCode": "94030", 
    "CountrySubDivisionCode": "CA"
  }, 
  "GivenName": "Bhavdip", 
  "PrintOnCheckName": "Bhavdip's Auto Shop"
}

Now I add the vendor using the C# code.

Vendor _vendor = new Vendor();
_vendor.GivenName = "bhavdip's Auto Shop";
_vendor.CompanyName = "bhavdip's Auto Shop";
_vendor.FamilyName = "Talaviya";

TelephoneNumber _PrimaryPhone = new TelephoneNumber();
_PrimaryPhone.FreeFormNumber = "9898989898";
_vendor.PrimaryPhone = _PrimaryPhone;

TelephoneNumber _Mobile = new TelephoneNumber();
_Mobile.FreeFormNumber = "(650) 555-2342";
_vendor.Mobile = _Mobile;

EmailAddress _Email = new EmailAddress();
_Email.Address = "bhavdip.vision@gmail.com";
_vendor.PrimaryEmailAddr = _Email;

PhysicalAddress _BillAddr = new PhysicalAddress();
_BillAddr.CountrySubDivisionCode = "CA";
_BillAddr.PostalCode = "94030";
_BillAddr.Country = "U.S.A";
_BillAddr.Line1 = "29834 Mustang Ave.";
_BillAddr.City = "Millbrae";

_vendor.BillAddr = _BillAddr;

WebSiteAddress _WeAddress = new WebSiteAddress();
_WeAddress.URI = "http://www.bhavdiptalaviya.com";
_vendor.WebAddr = _WeAddress;

_vendor.Active = true;
Vendor _vendorAdded = dataService.Add(_vendor);

you get the added vendor response in the  _vendorAdded so you can see or update to your DB.

Get Vendor

Query

Select * From Vendor

you can also make the query as you like below :

get vendor by LastUpdatedTime: select * from Vendor Where Metadata.LastUpdatedTime > ‘2015-03-01’

get vendor by ID: Select * From Vendor where Id = ‘1’

You need Realmid and AccessTocken for the get any data from the QuickBooks.

Now I get the all vendor using the C# code.

var realmid="add here your realm id";
var AccessTocken="add here your AccessTocken";

QueryService<Vendor> QueryService = new QueryService<Vendor>(GetContext(realmid, AccessTocken));
List<Vendor> _getVendor = QueryService.ExecuteIdsQuery("Select * From Vendor").ToList();

you get the vendor response in the _getVendor  variable so you can store this data into your DB.

Update Vendor

In update vendor, you need Quickbooks inserted Id and also SyncToken which get when the vendor added.

ATTRIBUTES

  • Id

    Datatype: string
    Unique identifier for this object. Sort order is ASC by default.
  • SyncToken

    Datatype: string
    The version number of the object. It is used to lock an object for use by one app at a time. As soon as an application modifies an object, its SyncToken is incremented. Attempts to modify an object specifying older SyncToken fails. Only the latest version of the object is maintained by QuickBooks Online.

Now I update the vendor using the C# code, here I update the only company name and email of the vendor.

Vendor _vendor = new Vendor();
 _vendor.CompanyName = "Talaviya's flower Shop";

 EmailAddress _Email = new EmailAddress(); 
 _Email.Address = "bhavdip@gmail.com";
 _vendor.PrimaryEmailAddr = _Email; 
 
 _vendor.Id = "1"; 
 _vendor.SyncToken = "1";
 Vendor _vendorUpdated = dataService.Update(_vendor);

 

you get the updated vendor response in the _vendorUpdated  so you can see or update to your DB.

you can not delete the vendor in QuickBooks online, you can update this vendor as In-active like below:
_vendor.Active = false;

so In this blog, I explained add vendor, update vendor and also get vendor.

Bhavdip Talaviya

I'm an Asp.net MVC, Angular developer at Surat. I am an open-minded individual with a proven track record in designing websites and creating databases. I have strong technical skills as well as excellent interpersonal skills. I am eager to be challenged in order to grow and improve my communication and professional IT skills gained through previous experiences in the IT sector

View Comments

  • 1st Thank you for your post. I needed to list the vendor addresses so in a web search I found your site. However, when I use: QueryService.ExecuteIdsQuery("Select * From Vendor").ToList()
    I do NOT see the Address,City,State and Zip
    What am I missing?

    I'm adding the data to a gridview for quick debug:
    GridView1.DataSource = queryService.ExecuteIdsQuery("Select * From Vendor").ToList();

Share
Published by
Bhavdip Talaviya

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

2 years ago