【问题标题】:How do I make a simple API call from a node app to the Intuit QuickBooks API?如何从节点应用程序对 Intuit QuickBooks API 进行简单的 API 调用?
【发布时间】:2021-10-24 04:55:45
【问题描述】:

我建立了一个简单的 Node 应用程序,最终目的是查询一堆 QuickBook API。然而,我想首先进行一个简单的 API 调用,以确保一切正常。如何配置我的应用程序来执行此操作?我一直在使用intuit oauth nodejs 库,并设置了我的快递应用程序如下:

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(`????️ Server listening on port ${port}`)
})

我的终端收到以下错误,这表明这是与令牌相关的问题:

statusCode=400","detail":"缺少必填参数:access_token

【问题讨论】:

    标签: node.js express oauth quickbooks


    【解决方案1】:

    在调用makeApiCall 方法之前,您必须执行authorization code flow

    关于 NPM 的文档也提到了sample application

    【讨论】:

      猜你喜欢
      • 2018-01-13
      • 2011-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-22
      相关资源
      最近更新 更多