# (POST API) Create a dynamique JSON code?

**URL:** <https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936>\
**Category:** Need help\
**Created:** [August 11, 2024, 11:53am UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936 "2024-08-11T11:53:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthieu3](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@matthieu3](https://forum.bubble.io/u/matthieu3)\
**Post date:** [August 11, 2024, 11:53am UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936/1 "2024-08-11T11:53:41Z")

</div>

Hello,

I need to create a dynamic JSON code to make a POST API ;

In my program, I can create a team, from 2 to x people.

If the team is made up of 2 people, then the JSON code would have to adapt dynamically and send the information as an API POST.

If the team is made up of 8 people, then the JSON code adapts dynamically and the right information is sent by POST API.

I have the impression that the JSON code can’t be dynamic on Bubble, i.e. I have to pre-program several POST APIs and, depending on the number of people, the right JSON is chosen and the information is then sent to the POST API.

So I’m coming to you for your opinion and to find out if you’ve managed to do something dynamic if you’ve come across the subject? Because in my case, if I provide the JSON code for up to 10 people, maybe one day my client will need to include 15 and then it won’t work…

What do you think ? How to do it ?

---

<div class="post-metadata">

**Author:** ![matthieu3](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@matthieu3](https://forum.bubble.io/u/matthieu3)\
**Post date:** [August 11, 2024, 12:03pm UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936/2 "2024-08-11T12:03:19Z")

</div>

Using JSON “text”, for example ;

Something like :

In the “API connector” plugin:

{  
\< dynamic-code-in-json-text-format \>  
}

And according to the choice of the number of members, bubble increments code in text format, which is then sent to “\< dynamic-code-in-json-text-format \>”

Is it possible to do this?

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [August 11, 2024, 3:32pm UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936/3 "2024-08-11T15:32:49Z")

</div>

You will use :formatted as text on a list of team for example. This way, you can dynamically create an array in JSON

---

<div class="post-metadata">

**Author:** ![matthieu3](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@matthieu3](https://forum.bubble.io/u/matthieu3)\
**Post date:** [August 12, 2024, 1:01am UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936/4 "2024-08-12T01:01:15Z")

</div>

Thanks a lot

Can you please show me an example if possible ?

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [August 12, 2024, 1:12pm UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936/5 "2024-08-12T13:12:12Z")

</div>

Not really, this depend of your JSON payload request. If you can share an example of the whole request, this could be possible to share an example.

---

<div class="post-metadata">

**Author:** ![matthieu3](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@matthieu3](https://forum.bubble.io/u/matthieu3)\
**Post date:** [August 12, 2024, 1:32pm UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936/6 "2024-08-12T13:32:03Z")

</div>

I understand, here is the JSON code ;

This is for 5 members, but i’m looking for creating ‘n’ members and the JSON code will be written dynamically

```auto
{
		"name": "<squad1-name>",
        "members": [
            {
                "assistantId": <id-Assistant1-squad>,
                "assistantDestinations": [
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant2-squad>",
                        "message": "<message-oral-ass1-vers-ass2>",
                        "description": "<condition-transfert-ass1-vers-ass2>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant3-squad>",
                        "message": "<message-oral-ass1-vers-ass3>",
                        "description": "<condition-transfert-ass1-vers-ass3>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant4-squad>",
                        "message": "<message-oral-ass1-vers-ass4>",
                        "description": "<condition-transfert-ass1-vers-ass4>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant5-squad>",
                        "message": "<message-oral-ass1-vers-ass5>",
                        "description": "<condition-transfert-ass1-vers-ass5>"
                    }
                ]
            },
            {
                "assistantId": <id-Assistant2-squad>,
                "assistantDestinations": [
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant1-squad>",
                        "message": "<message-oral-ass2-vers-ass1>",
                        "description": "<condition-transfert-ass2-vers-ass1>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant3-squad>",
                        "message": "<message-oral-ass2-vers-ass3>",
                        "description": "<condition-transfert-ass2-vers-ass3>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant4-squad>",
                        "message": "<message-oral-ass2-vers-ass4>",
                        "description": "<condition-transfert-ass2-vers-ass4>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant5-squad>",
                        "message": "<message-oral-ass2-vers-ass5>",
                        "description": "<condition-transfert-ass2-vers-ass5>"
                    }
                ]
            },
            {
                "assistantId": <id-Assistant3-squad>,
                "assistantDestinations": [
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant1-squad>",
                        "message": "<message-oral-ass3-vers-ass1>",
                        "description": "<condition-transfert-ass3-vers-ass1>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant2-squad>",
                        "message": "<message-oral-ass3-vers-ass2>",
                        "description": "<condition-transfert-ass3-vers-ass2>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant4-squad>",
                        "message": "<message-oral-ass3-vers-ass4>",
                        "description": "<condition-transfert-ass3-vers-ass4>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant5-squad>",
                        "message": "<message-oral-ass3-vers-ass5>",
                        "description": "<condition-transfert-ass3-vers-ass5>"
                    }
                ]
            },
            {
                "assistantId": <id-Assistant4-squad>,
                "assistantDestinations": [
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant1-squad>",
                        "message": "<message-oral-ass4-vers-ass1>",
                        "description": "<condition-transfert-ass4-vers-ass1>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant2-squad>",
                        "message": "<message-oral-ass4-vers-ass2>",
                        "description": "<condition-transfert-ass4-vers-ass2>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant3-squad>",
                        "message": "<message-oral-ass4-vers-ass3>",
                        "description": "<condition-transfert-ass4-vers-ass3>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant5-squad>",
                        "message": "<message-oral-ass4-vers-ass5>",
                        "description": "<condition-transfert-ass4-vers-ass5>"
                    }
                ]
            },
            {
                "assistantId": <id-Assistant5-squad>,
                "assistantDestinations": [
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant1-squad>",
                        "message": "<message-oral-ass5-vers-ass1>",
                        "description": "<condition-transfert-ass5-vers-ass1>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant2-squad>",
                        "message": "<message-oral-ass5-vers-ass2>",
                        "description": "<condition-transfert-ass5-vers-ass2>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant3-squad>",
                        "message": "<message-oral-ass5-vers-ass3>",
                        "description": "<condition-transfert-ass5-vers-ass3>"
                    },
                    {
                        "type": "assistant",
                        "assistantName": "<name-Assistant4-squad>",
                        "message": "<message-oral-ass5-vers-ass4>",
                        "description": "<condition-transfert-ass5-vers-ass4>"
                    }
                ]
            }
        ]
    }

```

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [August 12, 2024, 1:47pm UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936/7 "2024-08-12T13:47:51Z")

</div>

In API Connector

```auto
{
		"name": "<squad1-name>",
        "members": [<members>] ]
    }

```

In your “members” field, Do a search for members:formatted as text  
First box, probably something like

```auto
{
                "assistantId": This member assistand ID (dynamic),
                "assistantDestinations": [Do a search for destination:formatted as text with a constraint for current member]
            }

```

And comma for second box (delimiter)  
In the second formatted as text for destination

```auto
                    {
                        "type": "assistant",
                        "assistantName": "This assistant name (dynamic)",
                        "message": "This assistant message (dynamic)",
                        "description": "This description (dynamic"
                    }

```

Delimiter comma.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [October 20, 2024, 11:54am UTC](https://forum.bubble.io/t/post-api-create-a-dynamique-json-code/334936/8 "2024-10-20T11:54:12Z")

</div>

Closed on October 20, 2024, 11:54am UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
