# Urgent , Please how can i add Authorisation header to HTTPP request on node - red for API

**URL:** <https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273>\
**Category:** Developing Nodes\
**Created:** [25 November 2021 13:30 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273 "2021-11-25T13:30:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![AYo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayo/32/50481_2.png) [@AYo](https://discourse.nodered.org/u/AYo)\
**Post date:** [25 November 2021 13:30 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/1 "2021-11-25T13:30:21Z")

</div>

Hi Guys !

i often received this message `Authentication credentials were not provided.`

please i have been wondering how to add an authorisation API for GET request for HTTP request. on node -red.  
i have tried it on Post Man and it works very fine here is the result

```auto
[
    {
        "timestamp": "2021-11-22T22:40:00",
        "load_state": "ON",
        "load_w": 148.946,
        "output_wh_total": 4003.0,
        "output_wh_delta": 49.0,
        "solar_w": 0.0,
        "solar_v": 3.832,
        "input_wh_total": 0.0,
        "bat_v": 25.258,
        "state_of_charge": 100,
        "full_charges_count": 1,
        "deep_discharges_count": 0,
        "bat_chg_total_wh": 0,
        "bat_dis_total_wh": 4003,
        "bat_usable_ah": 0.0,
        "bat_temp": 36.148,
        "restart_detected": false,
        "signal_strength": -59,
        "error_flag": 0
    }
]

the API is `https://cloud-solar.com/api/v1/devices/xokM5P/reports?start=1637620800&end=1637620811`

and the header is ` Authorisation: Token 6d423a90252863e3f4cc068546617b452031d167`

just like this 
`
![image|690x450](upload://bBv4RQiOGDLVyFzwx4GBnlmMvkM.png)
`
![image|690x450](upload://bBv4RQiOGDLVyFzwx4GBnlmMvkM.png)

thanks

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 November 2021 13:47 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/2 "2021-11-25T13:47:17Z")

</div>

It depends on what the header needs to contain, but have you tried the 'Use authentication' option in the node?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/4/849f2d60616ac8c735197b16cb6f5c413c796a48.png)

---

<div class="post-metadata">

**Author:** ![AYo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayo/32/50481_2.png) [@AYo](https://discourse.nodered.org/u/AYo)\
**Post date:** [25 November 2021 13:53 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/3 "2021-11-25T13:53:13Z")

</div>

wow !

thanks for your reactivity.

yes but i don't know the username and the password.  
i am only having the unique API KEY

```auto
Authorisation: Token 6d423a90252863e3f4cc068546617b452031d167

```

thanks

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 November 2021 13:57 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/4 "2021-11-25T13:57:57Z")

</div>

Okay - so that isn't a standard format for the Authorisation header, so the node won't be able to set the header for you.

Instead, add a Function node before the HTTP Request node with:

```auto
msg.headers = {
   "Authorisation": "Token 1234...."
}
return msg

```

---

<div class="post-metadata">

**Author:** ![AYo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayo/32/50481_2.png) [@AYo](https://discourse.nodered.org/u/AYo)\
**Post date:** [25 November 2021 13:59 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/5 "2021-11-25T13:59:27Z")

</div>

thanks let me do it now,

thanks again !

---

<div class="post-metadata">

**Author:** ![AYo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayo/32/50481_2.png) [@AYo](https://discourse.nodered.org/u/AYo)\
**Post date:** [25 November 2021 14:07 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/6 "2021-11-25T14:07:07Z")

</div>

@knolleary  
that is exactly what i did

```auto
msg.headers = {
   "Authorisation": "Token 6d423a90252863e3f4cc068546617b452031d167"
}
return msg

```

but i get this `Authentication credentials were not provided.`

whereas it works well on post man

what do you thing might the issues?

---

<div class="post-metadata">

**Author:** ![AYo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayo/32/50481_2.png) [@AYo](https://discourse.nodered.org/u/AYo)\
**Post date:** [25 November 2021 14:11 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/7 "2021-11-25T14:11:54Z")

</div>

hi @knolleary

🕶🕶

thanks it is working now

```auto
{"timestamp":"2021-11-22T22:40:00","load_state":"ON","load_w":148.946,"output_wh_total":4003,"output_wh_delta":49,"solar_w":0,"solar_v":3.832,"input_wh_total":0,"bat_v":25.258,"state_of_charge":100,"full_charges_count":1,"deep_discharges_count":0,"bat_chg_total_wh":0,"bat_dis_total_wh":4003,"bat_usable_ah":0,"bat_temp":36.148,"restart_detected":false,"signal_strength":-59,"error_flag":0}

```

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [25 November 2021 14:22 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/8 "2021-11-25T14:22:57Z")

</div>

`Authorisation` should probably be `Authorization` (UK vs US English...)

---

<div class="post-metadata">

**Author:** ![AYo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayo/32/50481_2.png) [@AYo](https://discourse.nodered.org/u/AYo)\
**Post date:** [25 November 2021 14:24 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/9 "2021-11-25T14:24:52Z")

</div>

😊 yeah you are right that is what i corrected.

thanks too

---

<div class="post-metadata">

**Author:** ![AYo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ayo/32/50481_2.png) [@AYo](https://discourse.nodered.org/u/AYo)\
**Post date:** [25 November 2021 14:32 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/10 "2021-11-25T14:32:19Z")

</div>

@hardillb @knolleary

i am not so good in NodeJs,  
please how can i filter the the messages so that i will only debug few of the messages  
the messages are `{"timestamp":"2021-11-22T22:40:00","load_state":"ON","load_w":148.946,"output_wh_total":4003,"output_wh_delta":49,"solar_w":0,"solar_v":3.832,"input_wh_total":0,"bat_v":25.258,"state_of_charge":100,"full_charges_count":1,"deep_discharges_count":0,"bat_chg_total_wh":0,"bat_dis_total_wh":4003,"bat_usable_ah":0,"bat_temp":36.148,"restart_detected":false,"signal_strength":-59,"error_flag":0}`

i want to display these values

```auto
1."load_state"
2."bat_v"
3."load_w"
3. "bat_temp"

```

thanks fro your help !

---

<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:** [9 December 2021 14:33 UTC](https://discourse.nodered.org/t/urgent-please-how-can-i-add-authorisation-header-to-httpp-request-on-node-red-for-api/54273/11 "2021-12-09T14:33:11Z")

</div>

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