I have successfully been able to call an API using python requests library. Need to make the same request in node.js. Saw various Q&As on SO and tried hard with the request library in node.js but not able to make this work esp. with data and bearer authorization.
var request = require('request');
data = {
"Inputs": {
"input1":
[
{
'Col1': "5",
'Col2': "3.5",
'Col3': "1.5",
'Col4': "0.2",
'Col5': "doesnotmatter",
}
],
},
"GlobalParameters": {
}
}
var options = {
method: 'POST',
body: data,
json: true,
url: 'https://api.github.com/repos/request/request',
headers: {
'Authorization':'Bearer xxxx'
}
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body)
}
}
//call the request
request(options, callback);
For more refference you can go to request library repo.headers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With