I have a REST web service which works fine (Response code 200) when invoked from any browser, curl or from any other REST client like Postman. However when I invoke it from a NodeJs application running locally, it is giving 404. Following the NodeJS code which calls this API.
var http = require('http');
var options = {
host: '<end_point>',
port: 80,
path: '<path>',
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
};
http.request( options,
function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log(chunk);
});
}).end();
Suspecting a problem with above code, I tried to tweak it, but nothing worked. Is there any problem with above code?
The response headers when successfully invoked from Postman are
Content-Type →application/json
Date →Mon, 17 Apr 2017 10:25:03 GMT
Server →WSGIServer/0.2 CPython/3.4.5
via Ravi Chandra
No comments:
Post a Comment