# HTTP Post ; how to handle dynamic payload fields?

**URL:** <https://discourse.nodered.org/t/http-post-how-to-handle-dynamic-payload-fields/34069>\
**Category:** General\
**Created:** [10 October 2020 19:51 UTC](https://discourse.nodered.org/t/http-post-how-to-handle-dynamic-payload-fields/34069 "2020-10-10T19:51:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChillXXL](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chillxxl/32/30408_2.png) [@ChillXXL](https://discourse.nodered.org/u/ChillXXL)\
**Post date:** [10 October 2020 19:51 UTC](https://discourse.nodered.org/t/http-post-how-to-handle-dynamic-payload-fields/34069/1 "2020-10-10T19:51:38Z")

</div>

I have troubles finding a solution to make a dynamic payload in a function node to be a input for a HTTP (Post) node.

The payload need to be formated like:

```auto
msg.payload = {
  "key_1": "value_1"
};

```

The "key\_1" is a dynamic key and the "value\_1" in this example is fixed.

The question is; _how do I make the "key\_1" string a string that can be filled by a variabele?_

---

<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:** [10 October 2020 20:11 UTC](https://discourse.nodered.org/t/http-post-how-to-handle-dynamic-payload-fields/34069/2 "2020-10-10T20:11:45Z")

</div>

```auto
let v = "key_1"
let msg.payload = {}
msg.payload[v] = "value_1"

```

Untested as typed on phone

---

<div class="post-metadata">

**Author:** ![ChillXXL](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chillxxl/32/30408_2.png) [@ChillXXL](https://discourse.nodered.org/u/ChillXXL)\
**Post date:** [10 October 2020 21:11 UTC](https://discourse.nodered.org/t/http-post-how-to-handle-dynamic-payload-fields/34069/4 "2020-10-10T21:11:56Z")

</div>

> [@Colin](#):
>
> ```auto
> let v = "key_1"
> let msg.payload = {}
> msg.payload[v] = "value_1"
> 
> ```
> 
> Untested as typed on phone

Thanks! I putted the variable between the brackets "[]" and it worked! 🙂

---

<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:** [24 October 2020 21:12 UTC](https://discourse.nodered.org/t/http-post-how-to-handle-dynamic-payload-fields/34069/5 "2020-10-24T21:12:02Z")

</div>

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