POST request to servicenow from NodeJS

nahidalam
Kilo Contributor

Hi

I am trying to create a new ticket to servicenow by sending a POST request from my NodeJS application.

Initially I wrote the below code:

var request = require('request');

request.post(

      'https://MYINSTANCE.service-now.com/api/now/v1/table/incident',

      { json: { key: 'value' } },

      function (error, response, body) {

              if (!error && response.statusCode == 200) {

                      console.log(body)

              }

else {

console.log("error")

}

      }

);

This returns an html instead of a JSON. What am I missing?