# HTTP post Content-Type header not working

**URL:** <https://discourse.nodered.org/t/http-post-content-type-header-not-working/38596>\
**Category:** General\
**Created:** [5 January 2021 15:33 UTC](https://discourse.nodered.org/t/http-post-content-type-header-not-working/38596 "2021-01-05T15:33:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [5 January 2021 15:33 UTC](https://discourse.nodered.org/t/http-post-content-type-header-not-working/38596/1 "2021-01-05T15:33:15Z")

</div>

I'm attempting to send an http post request to an API. I can send it successfully using [https://apitester.com/](https://apitester.com/) online API tester but when I try it with Node-Red I get a 302 error. The one variable i've found that gets me the same error with the online tester is not setting the Content-Type to application/json.  
When I set this in node red the returned payload has Content-Type text/html; charset=UTF-8  
This is in my function node:

```auto
msg.headers = {
  'Authorization': 'Bearer', 
  "Content-Type" : "application/json"
};

msg.data = {
  "checkout_to_type": "location",
  "assigned_location": 1,
  "location_id": msg.location
}

return msg;

```

---

<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 January 2021 16:13 UTC](https://discourse.nodered.org/t/http-post-content-type-header-not-working/38596/2 "2021-01-05T16:13:32Z")

</div>

> [@JohnnyPicnic](#):
>
> `msg.data = {`

what happens if you change this to `msg.payload = {`

---

<div class="post-metadata">

**Author:** ![JohnnyPicnic](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnnypicnic/32/34787_2.png) [@JohnnyPicnic](https://discourse.nodered.org/u/JohnnyPicnic)\
**Post date:** [5 January 2021 17:09 UTC](https://discourse.nodered.org/t/http-post-content-type-header-not-working/38596/3 "2021-01-05T17:09:09Z")

</div>

Yup that did it. Thank you very much.  
Is it because the http node automatically takes the payload moves it to data?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 January 2021 21:22 UTC](https://discourse.nodered.org/t/http-post-content-type-header-not-working/38596/4 "2021-01-05T21:22:30Z")

</div>

It is because using msg.payload is what is documented in the help text for the node.

---

<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 January 2021 21:22 UTC](https://discourse.nodered.org/t/http-post-content-type-header-not-working/38596/5 "2021-01-19T21:22:41Z")

</div>

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