I'm having a problem in posting data in node.js with Content-type: 'application/x-www-form-urlencoded'
var loginArgs = {
data: 'username="xyzzzzz"&"password="abc12345#"',
//data: {
// 'username': "xyzzzzz",
// 'password': "abc12345#",
//},
headers: {
'User-Agent': 'MYAPI',
'Accept': 'application/json',
'Content-Type':'application/x-www-form-urlencoded'
}
};
And post request is:
client.post("http:/url/rest/login", loginArgs, function(data, response){
console.log(loginArgs);
if (response.statusCode == 200) {
console.log('succesfully logged in, session:', data.msg);
}
It always returns username/password incorrect.
In the rest api it is said that the request body should be:
username='provide user name in url encoded
format'&password= "provide password in url encoded format'