# Http-request node not working

**URL:** <https://discourse.nodered.org/t/http-request-node-not-working/27828>\
**Category:** General\
**Created:** [5 June 2020 11:45 UTC](https://discourse.nodered.org/t/http-request-node-not-working/27828 "2020-06-05T11:45:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vamp](https://avatars.discourse-cdn.com/v4/letter/v/f4b2a3/32.png) [@Vamp](https://discourse.nodered.org/u/Vamp)\
**Post date:** [5 June 2020 11:45 UTC](https://discourse.nodered.org/t/http-request-node-not-working/27828/1 "2020-06-05T11:45:34Z")

</div>

Hello there,

I try to use Axxon VMS endpoint API.

**[https://doc.axxonsoft.com/confluence/display/next436en/HTTP+API](https://doc.axxonsoft.com/confluence/display/next436en/HTTP+API)**

A simple info with server:

curl:

```auto
vamp@ubuntu:~$ curl http://root:root@localhost:8000/hosts/DEBIAN

{
  "hostname": "DEBIAN"
  ,"domainInfo":
  {
    "domainName": "3518d676-c243-47d7-9530-4c2edbf71c80"
    ,"domainFriendlyName": "test"
  }
  ,"platformInfo":
  {
    "machine": "x86_64"
    ,"os": "Linux"
  }
  ,"licenseStatus": "OK"
  ,"timeZone": 120
}

```

wget:

```auto
vamp@ubuntu:~$ wget -O - http://root:root@localhost:8000/hosts/DEBIAN
--2020-06-05 13:41:13-- http://root:*password*@localhost:8000/hosts/DEBIAN
localhost (localhost) feloldása… 
Csatlakozás a következőhöz: localhost (localhost)[]:8000… kapcsolódva.
HTTP kérés elküldve, várakozás válaszra… 401 Unauthorized
Hitelesítés kijelölve: Basic realm="AxxonNext"
Csatlakozás a következőhöz: localhost(localhost)[]:8000… kapcsolódva.
HTTP kérés elküldve, várakozás válaszra… 200 OK
Hossz: 259 [application/json]
Mentés ide: „STDOUT”

- 0%[] 0 --.-KB/s
{
  "hostname": "DEBIAN"
  ,"domainInfo":
  {
    "domainName": "3518d676-c243-47d7-9530-4c2edbf71c80"
    ,"domainFriendlyName": "test"
  }
  ,"platformInfo":
  {
    "machine": "x86_64"
    ,"os": "Linux"
  }
  ,"licenseStatus": "OK"
  ,"timeZone": 120
}

- 100%[======================================================================================>] 259 --.-KB/s idő 0s

2020-06-05 13:41:13 (27,4 MB/s) -- kiírva a szabványos kimenetre [259/259]

```

But http\_reguest node get this:

```auto
msg : Object
object
_msgid: "4c1bbed.e572a4"
topic: ""
payload: ""
statusCode: 401
headers: object
access-control-allow-origin: "*"
connection: "Close"
www-authenticate: "Basic realm="AxxonNext""
x-node-red-request-node: "2eb3793b"
responseUrl: "http://localhost:8000/hosts/DEBIAN"
redirectList: array[0]

```

I use basic auth. on node. I also try to add auth. inside the link, but not work at all.

Any idea?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 June 2020 12:13 UTC](https://discourse.nodered.org/t/http-request-node-not-working/27828/2 "2020-06-05T12:13:16Z")

</div>

Is node-red running on the same machine as the API?

(To clarify, I mean the node-red server not the client browser)

Also, you could possibly try to set basic Auth in the headers with base64 encoded user:pass

Eg

`Authorization: Basic cm9vdDpyb2l0`

[https://www.blitter.se/utils/basic-authentication-header-generator/](https://www.blitter.se/utils/basic-authentication-header-generator/)

---

<div class="post-metadata">

**Author:** ![Vamp](https://avatars.discourse-cdn.com/v4/letter/v/f4b2a3/32.png) [@Vamp](https://discourse.nodered.org/u/Vamp)\
**Post date:** [5 June 2020 12:19 UTC](https://discourse.nodered.org/t/http-request-node-not-working/27828/3 "2020-06-05T12:19:19Z")

</div>

Nevermind, i found the problem...

in http-request node, i set the basic-auth, but in not enught...

Need a function node before http-request that set this in header:

```auto
msg.headers = {};
msg.headers['Authorization'] = 'Basic';
return msg;

```

I don't know why needed, but now it working...

Edit: Yes you wrote the sollution, but not need the base64 encoding, only set it to 'basic'.

---

<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:** [19 June 2020 12:19 UTC](https://discourse.nodered.org/t/http-request-node-not-working/27828/4 "2020-06-19T12:19:21Z")

</div>

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