Anybody have a NodeJs sample of request using TBA(...
# suitescript
a
Anybody have a NodeJs sample of request using TBA(oAuth 1.0)???
s
Copy code
test('payload with same SKU on two lines should succeed', done => {
    // after first run this one should be identified as a 'dupe' but still return 'SUCCESS'
    const data = require('./payloads/EC_Restlet_eComm_RMAmultiplelines.json')
    <http://http.post|http.post>({body: data, json: true, ...baseConfig}, function (e, r, body) {
      console.debug(body)
      expect(body.status).toEqual('SUCCESS')
      done()
    })
  })
a
And the payload JSON structure is?
s
where
baseConfig
is something like
Copy code
/**
 * OAuth config - replace <> placeholders with your values
 */
const oauth = {
  // replace the values with your TBA consumer values from NS
  consumer_key: 'foo',
  consumer_secret: 'bar',
  // replace with token TBA values from NetSuite
  token: 'baz',
  token_secret: 'bog',
  realm: 'someaccount_SB2'
}

/**
 * configuration used for passing to the node *request* object
 *
 * @example
 *   baseConfig.url = <https://path/to/restlet/endpoint
 *  <http://http.post|http.post>({body: payload, json: true, ...baseConfig}, function (e, r, body) { } )
 */
export const baseConfig = {
  //  EC_Restlet_PostEcomm_Order on DEV environment
  url: 'path to restlet endpoint',
  oauth: oauth
}
and the
<http://http.post|http.post>()
is just the
request
module
a
That should do it let me test...
s
the payload json structure is irrelevant, since OAuth takes place in headers, not the body. So in this case the payload is simply the JSON the receiving business logic script needs to work with.
a
Thanks
s
hmm, why can't you add a 'code to text snippet' inside a thread using the [+] button at left?
a
Copy code
var code = {};
No idea...