0

I should to send curl post request to remote server(nodejs) :

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'

I try something like this:

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);
    }
});

But its not working. I had only 400 response.

ItsMyLife
  • 458
  • 7
  • 21

0 Answers0