Joel Wembo
Joel Wembo

Reputation: 870

Nodejs NetSuite-rest module : Invalid content in the request body

I am getting this error while connecting Nodejs app to NetSuite web services : StatusCodeError: 400 - "{"type":"https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1","title":"Bad Request","status":400,"o:errorDetails":[{"detail":"Invalid content in the request body.","o:errorCode":"INVALID_CONTENT"}]}\n"

var dotenv = require("dotenv");
dotenv.config();

console.log('Token', process.env.token);
console.log('Token Secret', process.env.token_secret);

var NsApiWrapper = require('netsuite-rest');
NsApi = new NsApiWrapper({
   consumer_key: process.env.consumer_key,
   consumer_secret_key: process.env.consumer_secret_key,
   token: process.env.token,
   token_secret: process.env.token_secret,
   base_url: "https://xxxx.suitetalk.api.netsuite.com",
   realm: process.env.realm,
 });

   NsApi.request({
       path: 'query/v1/suiteql?limit=5',
       method: "POST",
       body: `{
      "q": 
           "SELECT 
           id, companyName, email, dateCreated
           FROM accounts"
       }`
      })
       .then(response => console.log(response))
       .catch((err) => console.log(err));

Upvotes: 1

Views: 870

Answers (1)

2ps
2ps

Reputation: 15926

The endpoint that you are using uses the analytics framework and not the connect framework. The account table would be closest to the accounts in your query, but would not contain the fields that you are looking for. If you were looking for vendor accounts, you can use the vendor table:

select id, email, companyname, datecreated from vendor

Upvotes: 1

Related Questions