- Require needed libraries (querystring, https).
- Create your inquiry data array.
- Create your http options.
- Make a callback function to handle the response from the http call and pass it into the http request.
- Process the response object in the callback function.
var querystring = require('querystring'); var https = require('https'); var data = querystring.stringify( { "ANID":"0123456789", "AUTH":"A", "CURR":"USD", "EMAL":"tptst15@gmail.com", "IPAD":"127.0.0.1", "MACK":"Y", "MERC":"900200", "MODE":"Q", "PTOK":"4111111111111111", "PTYP":"CARD", "SESS":"-86ae-e111f23009fb-208152759", "SITE":"DEFAULT", "VERS":"0630", "TOTL":"90000", "PROD_DESC[0]":"FlightBooking", "PROD_ITEM[0]":"Online Flight Booking", "PROD_PRICE[0]":"699", "PROD_QUANT[0]":1, "PROD_TYPE[0]":"Flight Trip Booking", } ); var options = { host: 'risk.test.kount.net', path: '/', port: '443', method: 'POST', //This is the only line that is new. `headers` is an object with the headers to request headers: {'X-Kount-Api-Key': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5MDAyMDAiLCJhdWQiOiJLb3VudC4xIiwiaWF0IjoxNDQwNzA5NTA4LCJzY3AiOnsia2EiOm51bGwsImtjIjpudWxsLCJhcGkiOnRydWUsInJpcyI6dHJ1ZX19.avXaZopGLCPgaosWbF9weJISAtkPAjafEiZXrL7m978', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(data) } }; callback = function(response) { var str = '' response.on('data', function (chunk) { str += chunk; }); response.on('end', function () { console.log(str); }); } var req = https.request(options, function(res) { res.setEncoding('utf8'); res.on('data', function (chunk) { console.log("body: " + chunk); }); }); req.write(data); req.end();