Search code examples
node.jsglassfishnode-red

Requesting API leads to success on browser but status code 500 in node-red


I'm trying to call an API with "http request" node in node-red (node.js).
After setting an enviroment variable "HTTP_PROXY=http://******", I could call Web pages (such as "http: //google.com") with a response of status code 200, but failed to call the API with status code 500 in node-red. I could call the API by entering URL directly on browser (Internet Explorer).
How can I solve the problem and call the API in node-red(node.js)? (what's the difference between the two means (node-red and browser))?


Solution

  • You have verified that the API is expecting certain headers, and throws an exception without them (ouch, bad practice!).

    Anyway, to invoke the API with additional headers, you can use a change node to add them to the msg object, right before invoking the http request node:

    enter image description here