For a web application I'm trying to pull some data from a RESTful service which requires basic authentication.
So far I've got the following code:
var req = request({
auth: 'Basic aGVsbG8gd29ybGQ=', //base64 encoded credentials "hello world"
url: url.resolve("https://rest.someurl.com", "/url/to/data.xml"),
method: "GET",
jar: true
}, function(err, res, body) {
if(err) return util.err(err);
console.log(body);
});
When I pull this URL through Postman service with the authentication header set it returns the data properly. Also when I remove the auth option and enter the username/password in the URL directly I also get the data back as normal. The only situation I don't get any data back is with my code above.
What's wrong with my code above or what should I add to it to make it work?