我应该向远程服务器(nodejs)发送curl post请求:
curl -X POST \
--header 'Content-Type: application/json; charset=utf-8' \
--header 'Accept: application/json' \
-d '{"email":"voluumdemo@voluum.com","password":"1qaz!QAZ"}' \
'https://api.voluum.com/auth/session'
我尝试这样的事情:
var request = require('request');
var headers = {
'Content-Type': 'application/json; charset=utf-8',
'Accept': 'application/json'
};
var options = {
url: 'https://api.voluum.com/auth/session',
method: 'POST',
headers: headers,
data: {"email":"voluumdemo@voluum.com","password":"1qaz!QAZ"}
};
request(options, function (error, response, body) {
console.log('Res:'+response.statusCode);
console.log('err:'+error);
if (!error && response.statusCode == 200) {
// Print out the response body
console.log(body);
}
});
但它不起作用。我只有400回应。