Question

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
Was it helpful?

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

OTHER TIPS

Intuit Anywhere Developer Playground provides facility to get accessToken, accessTokenSecret and realmId.

Go to QuickBooks playground by clicking link mentioned below –

https://appcenter.intuit.com/Playground/OAuth/IA

Make sure that you are already logged into your Intuit account.

Fill consumer Key, Consumer Secret and Access Token Duration (120000 seconds).

enter image description here

Click on Connect to QuickBooks icon as shown in the picture. You will be asked to select company. If you have more than one company connected to your sandbox account, choose any according to your requirement. Then click Authorize Button.

You will get Access Token, Access Token Secret, RealmId (Company Id) and DataSource. Now you have all the keys to implement Accounting API. These keys will expire after 120000 seconds.

I have written a blog on how you can add, update, find and delete Customer.

https://vivekkumar11432.wordpress.com/2016/06/07/implement-intuits-quickbooks-online-api-in-restful-service-c/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top