Http request 401 Unauthorized - User authentication is required

Hello everyone,
I work in the world of building automation, I started with Note-Red a few days ago. in my Flow I have foreseen a first part in modbus ip client, then it asks the server (home automation system) for the status of the buttons of the command keyboards.
The other part that I cannot get to work should send http commands to another home automation system for the activation of the lighting scenarios.
Using the http request form with basic, user and pwd protection I get an authentication error.
For clarity I make an example of command:
http://192.168.1.201/SetDyNet.cgi?a=151&p=1
During my tests I also used the Postman program and with that it works perfectly.
To understand where the error occurs, I also entered the "http logger" node in the flow and I receive the following response:
13/9/2020, 18: 42: 52node: http debug
success: msg: Object
object
request: object
port: 80
path: null
host: "192.168.1.201"
href: "http://192.168.1.201/SetDyNet.cgi?a=151&p=1"
method: "GET"
headers: object
host: "192.168.1.201"
authorization: "Basic YWRtaW46YWRtaW4 ="
connection: "keep-alive"
body: ""
response: object
statusCode: 200
headers: object
trailers: object
httpVersion: "1.1"
url: ""
method: null
body: " 401 Unauthorized - User authentication is required. "
topic: "success"
_msgid: "e7497af9.d94448"

Thanks in advance

Hi @pm.integrator,

So to summarize:

  • When you use basic authentication in the http-request node, my http-logger node shows that your request contains correctly the required http header authorization: "Basic YWRtaW46YWRtaW4 =".
  • When you call the same url from Postman (using basic authentication also), it works fine.

No idea, but perhaps you can try to get the request that is being send by Postman (see how), and compare it to the request triggered by the http-request node.

I assume you have entered your basic authentication info in the config screen of the http-request node?

Bart

If you wrap code and log output in backticks, it makes it a lot easier to read.

Hi Bart,
Yes I entered as user "admin" and as always pass "admin" without special characters, but it doesn't work, I don't know how to solve it, and about a week I work with Node-Red.
We welcome suggestions thanks for your cooperation.
Piero.

Have you tried this?

Yes I tried to compare them, but there are fields that do not match, I thought it was a known problem, even with other programs around the internet the http request is always successful, I don't know how it is possible.

Yes but there must be something in the request from postman, that is not correct in the request from the http-request node. Try this one. Perhaps the server requires you to send a user-agent in the http header. That will most probably be available in the postman request (please check that!), because your browser will fill that header field with information about the browser. Please try to set the user-agent field, as described in the link that I have provided!