U
U
Uryuk2018-11-10 03:43:45
Node.js
Uryuk, 2018-11-10 03:43:45

How to log in to another server correctly and not get a 400 error?

How to log in to another server correctly and not get a 400 error?
Here is how I am trying to do it now

const https = require('https');
const options = {
hostname: 'site.com',
port: 443,
path: '/api/v1/',
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form- urlencoded',
'Content-Length': {
username: "myname",
password: "pass"
}
}
};
// api/v1/task_report/
const req = https.request(options, (res) => {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers) ;
console.log('headers:', res.body);
res.on('data', (d) => {
process.stdout. write(d);
});
});
req.on('error', (e) => {
console.error(e);
});
req end();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question