var req ={
"request": {
"header": {
"username": "name",
"password": "password"
},
"body": {
"shape":"round"
}
}
};
request.post(
{url:'posturl',
body: JSON.stringify(req),
headers: { "content-type": "application/x-www-form-urlencoded"}
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body)
}
}
);
I want to send raw request body in req variable . It is working on postman but in node js i am not able to send the raw json as request body for post request .
"content-type": "application/x-www-form-urlencoded"be incorrect, since you're sending JSON? It should beapplication/json.