I am sendin a request from node server to some other server , but i need to send content type
application/json
How can i send that , I am using this format
request.post('https://server.com/index.php/rest/V1/integration/admin/token',{form:postData},function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
res.json({
'error': error,
'statusCode': response && response.statusCode,
'body': body
})
});
I am getting error while I am trying this
request.post(
'https://server.com/index.php/rest/V1/integration/admin/token',
{
form:postData,
headers:{
"Content-Type": "application/json"
}
},function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
res.json({
'error': error,
'statusCode': response && response.statusCode,
'body': body
})
});
"message":"Server cannot understand Content-Type HTTP header media type application/x-www-form-urlencoded"