Search code examples
c#intuit-partner-platformquickbooks-online

Creating Customer in Quickbooks Online from C#


I need to add new customers to QuickBooks Online from C#.

I'm struggling to find any working end-to-end samples. Based on this: how to add invoice or sales receipt quickbooks rest api v3.0 I need accessToken, accessTokenSecret, consumerKey, consumerKeySecret, realmId.

Based on this: IPP .NET SDK for QuickBooks v3.0 Create Invoice Error - Bad Request I need accessToken, accessTokenSecret, consumerKey,consumerKeySecret, appToken, companyId.

I only have App Token, Oauth Consumer Key, OAuth consumer Secret, possibly realmId (App ID)

Where do I find the access token, access token secret, realm id and/or company ID?

I don't have a reputation to post images, but the developer settings page on https://developer.intuit.com/Application/Manage/IA?appId=XXX shows the following informations:

App ID: what is this? realm Id, company id?

App Token,OAuth Consumer Key,OAuth Consumer Secret

I'm using the QuickBooks Online REST API v3.0 for .Net

The code follows:

   var customer = new Customer();

   customer.GivenName = txtFirstName.Text;
   customer.FamilyName = txtLastName.Text;
   customer.MiddleName = txtMiddleName.Text;
   customer.CompanyName = txtCompany.Text;

   customer.PrimaryEmailAddr = new EmailAddress() { Address = txtEmail.Text, Default = true };
   customer.PrimaryPhone = new TelephoneNumber() { FreeFormNumber = txtPrimaryPhone.Text };


   OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
   ServiceContext context = new ServiceContext(accessToken, consumerKey, IntuitServicesType.QBO, oauthValidator);

   DataService service = new DataService(context);
   var c = service.Add(customer);
   // do something with c.Id

Solution

  • You need to implement the 3 legged oauth flow in your app using C2QB button to get the access token and secret. Please see our sample apps to see how this is implemented. Download the sample app and then configure the consumer key and secret in the config file. Then check how the 3-legged oauth happens.You can try making calls to the V3 API using the local copy of the sample apps too. https://github.com/IntuitDeveloperRelations/ Also refer: https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started