I am trying to post form-data content type using node js request, but every time I am getting a response 'null', I can do the same and get the correct response using the post man, I really don’t know what is wrong in the code, here is my source
var req = require('request');
req.post({
url: 'url’,
form: {request:[{"request":"context","sequence":0,"userToken":"mytokenxyz"}]},
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36',
'Content-Type' : 'application/x-www-form-urlencoded'
},
method: 'POST'
},
function (e, r, body) {
console.log(body); //here the body I am getting null
});
Here is the postman screenshot where I am getting the correct response. I tried a number of other ways but ends up in the same null response.
The issue was due to the Backslash in the mytokenxyz that wasn't escaped properly
form: {request:[{"request":"context","sequence":0,"userToken":"mytokenxyz"}]},
the actual token was B4nx4tt4m!\\MK_API