Home > other >  How do I make a simple API call from a node app to the Intuit QuickBooks API?
How do I make a simple API call from a node app to the Intuit QuickBooks API?

Time:10-26

I've set up a simple Node app, with the eventual aim of querying a bunch of QuickBook APIs. I however want to start off by making a single, simple API call just to make sure everything is working. How do I configure my app to do this? I've been using the intuit oauth nodejs library, and have set up my express app as follows:

index.js

const express = require('express')
const { environment } = require('intuit-oauth')
const OAuthClient = require('intuit-oauth')

const port = process.env.PORT || 5000
const app = express()

const oauthClient = new OAuthClient({
    clientId:'*****',
    clientSecret: '*****',
    environment: 'sandbox',
    redirectUri: 'https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl',
    logging:true
})


  oauthClient
  .makeApiCall({
    url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/{companyId}/account/1?minorversion=14',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    }
  })
  .then(function (response) {
    console.log('The API response is  : '   response);
  })
  .catch(function (e) {
    console.log('The error is '   JSON.stringify(e));
  });


app.listen(port, () => {
    console.log(`           
  • Related