I am trying to consume data from OAuth Enabled get API call in NodeJS. I need to pass two Online-Magazine-Subscription-Key and access token. I used 'request' module to consume API call.
var accessToken = 'Bearer xxx...xxx';
request.get({
url: URL,
headers: { 'accept': 'application/json', 'Online-Magazine-Subscription-Key': 'x..xxx', 'Authorization': accessToken}
}, function (err, res) {
console.log(err);
console.log(res);
});
Its throwing error as "{ [Error: tunneling socket could not be established, cause=Parse Error] code: 'E CONNRESET' }". But the same API call is working fine in Rest Client and all other similar stuff.
Response is always undefined. Did I missed any thing in the above code?? Is there any other way to consume OAuth Enabled API Calls??
Copyright Notice:Content Author:「ShaMoh」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/37678155/nodejs-consume-oauth-get-api-call