# Http request 401 Unauthorized - User authentication is required

**URL:** <https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825>\
**Category:** Industrial\
**Created:** [13 September 2020 16:57 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825 "2020-09-13T16:57:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pm.integrator](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@pm.integrator](https://discourse.nodered.org/u/pm.integrator)\
**Post date:** [13 September 2020 16:57 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825/1 "2020-09-13T16:57:08Z")

</div>

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](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](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

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [13 September 2020 21:15 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825/2 "2020-09-13T21:15:07Z")

</div>

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](https://blog.postman.com/debugging-postman-requests/)), 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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 September 2020 23:36 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825/3 "2020-09-13T23:36:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pm.integrator](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@pm.integrator](https://discourse.nodered.org/u/pm.integrator)\
**Post date:** [14 September 2020 14:37 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825/4 "2020-09-14T14:37:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [14 September 2020 14:43 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825/5 "2020-09-14T14:43:12Z")

</div>

> [@BartButenaers](#):
>
> perhaps you can try to get the request that is being send by Postman (see [how](https://blog.postman.com/debugging-postman-requests/)), and compare it to the request triggered by the http-request node.

Have you tried this?

---

<div class="post-metadata">

**Author:** ![pm.integrator](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@pm.integrator](https://discourse.nodered.org/u/pm.integrator)\
**Post date:** [14 September 2020 14:53 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825/6 "2020-09-14T14:53:25Z")

</div>

> [@BartButenaers](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [14 September 2020 15:02 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825/7 "2020-09-14T15:02:57Z")

</div>

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](https://discourse.nodered.org/t/http-request-set-user-agent/3269/2) 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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 November 2020 15:03 UTC](https://discourse.nodered.org/t/http-request-401-unauthorized-user-authentication-is-required/32825/8 "2020-11-13T15:03:08Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
