# Dynamic HTTP Request JSON Formatting

**URL:** <https://community.n8n.io/t/dynamic-http-request-json-formatting/205084>\
**Category:** Questions\
**Created:** [13 Octubre, 2025 21:22 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084 "2025-10-13T21:22:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous-Monk](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Anonymous-Monk](https://community.n8n.io/u/Anonymous-Monk)\
**Post date:** [13 Octubre, 2025 21:22 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084/1 "2025-10-13T21:22:24Z")

</div>

Hello!

I have a Workflow that makes an HTTP Request call and GETs an Agent’s metadata.

With that metadata, the agent calls a new HTTP POST call to our server, in which the body of the POST call is filled in by the model. In the description I have provided the model with the schema it should follow. Our server requires the body to be application/json for an HTTP request. The model is able to successfully follow the schema, however, it always creates a Array when it should be creating a Object.

I am not sure, how to go about figuring this out. Since the Body of the HTTP call is filled in by the Agent, I keep running into errors when trying to set the Content Type or Specify Body as an Expression.

I have tried different variations such as

Body Content Type: RAW  
Content Type: application/json

OR

Body Content Type: JSON  
Specify Body: Using JSON

 ![Screenshot1](https://europe1.discourse-cdn.com/n8n/original/3X/1/0/10b28495b95f0eeb4996fe367777a7f3c260f4e2.png)

Here is part of the description, given to the Model:  
{  
“name”: “AGENT-IMPORTS-WORKFLOW-NAME-FROM-TOOL”,  
“description”: “AGENT-CREATES-DESCRIPTION”,  
…  
“attributes”: {AGENT-FILLS-IN-FROM-TOOL}  
}

Within the Agent System Message, I have written extensive information, guidelines, and proper formatting. The Agent seems to follow everything correctly, I think it is n8n related with JSON Arrays vs Objects.

Is there a better method of doing this? I am fairly new to n8n and experimenting with the platform. I am unable to share the link to my exact workflow due to company policy, can attach screenshots with some omitted information.

I am running n8n locally, version 1.109.2. Any help would be great!

---

<div class="post-metadata">

**Author:** ![mohamed3nan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohamed3nan/32/188347_2.png) [@mohamed3nan](https://community.n8n.io/u/mohamed3nan)\
**Post date:** [13 Octubre, 2025 22:05 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084/2 "2025-10-13T22:05:29Z")

</div>

Hi @Anonymous-Monk

Can you try changing the `type` to `json` in the `$fromaAI` like this:

```auto
{{ $fromAI('Body', `your description `, 'json') }}

```

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/2/c/2cd05d916748eb89b81dbcc304978ee248fada51.png)

---

<div class="post-metadata">

**Author:** ![Anonymous-Monk](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Anonymous-Monk](https://community.n8n.io/u/Anonymous-Monk)\
**Post date:** [14 Octubre, 2025 16:32 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084/3 "2025-10-14T16:32:08Z")

</div>

Hi, thank you for such a speedy response.

Trying this yields the same problem, it is able to convert into a JSON but still is in an array and still includes “Body”:

 ![Screenshot2](https://europe1.discourse-cdn.com/n8n/original/3X/6/d/6db9f5c241c17addfef7b947adbc9a4cd9a68db0.png)

---

<div class="post-metadata">

**Author:** ![mohamed3nan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohamed3nan/32/188347_2.png) [@mohamed3nan](https://community.n8n.io/u/mohamed3nan)\
**Post date:** [14 Octubre, 2025 16:40 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084/4 "2025-10-14T16:40:52Z")

</div>

Try explicitly telling the model that you want a JSON **object** , You can add something like “ **Return a JSON object** ” to your prompt.

---

<div class="post-metadata">

**Author:** ![mohamed3nan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohamed3nan/32/188347_2.png) [@mohamed3nan](https://community.n8n.io/u/mohamed3nan)\
**Post date:** [14 Octubre, 2025 16:51 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084/5 "2025-10-14T16:51:12Z")

</div>

I think it’s about the prompt/instructions and the model at this point,

here is an example

---

<div class="post-metadata">

**Author:** ![Anonymous-Monk](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Anonymous-Monk](https://community.n8n.io/u/Anonymous-Monk)\
**Post date:** [14 Octubre, 2025 17:17 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084/6 "2025-10-14T17:17:13Z")

</div>

I will try debugging further. I am using Claude 3.5 Sonnet, we really only get access to Anthropic (3 and 3.5) models through AWS Bedrock. Furthermore, I have the Agent Instructions to follow xml formatting for improved performance and have noted multiple times to return a JSON object. When changing the the key from $fromAI(‘key’, ‘description’, ‘type’) the ‘key’ always shows despite changing the name and it is not possible to remove the key. Is it possible to specifically pull all the data within ‘key’ (in the screenshot case ‘json’)?

 ![Screenshot 2025-10-14 at 1.14.21 PM](https://europe1.discourse-cdn.com/n8n/original/3X/b/1/b16d6b82f8a618f8562472c485ab237b2c97c0a1.png)

```json
[  
 {     
   "key": {          
         "name": "John Doe",
         ...
    }
  }
]

```

I appreciate all your help!

---

<div class="post-metadata">

**Author:** ![mohamed3nan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohamed3nan/32/188347_2.png) [@mohamed3nan](https://community.n8n.io/u/mohamed3nan)\
**Post date:** [14 Octubre, 2025 17:31 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084/7 "2025-10-14T17:31:56Z")

</div>

> [@Anonymous-Monk](#):
>
> When changing the the key from $fromAI(‘key’, ‘description’, ‘type’) the ‘key’ always shows despite changing the name and it is not possible to remove the key

It doesn’t matter because the data being sent only includes the **object values**.

Look at this example in the screenshot:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/2/5/2555df2fb21472c23ea7f9bc0ac4d6c19e318c57.png)

Only the object values are sent..

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [12 Enero, 2026 17:32 UTC](https://community.n8n.io/t/dynamic-http-request-json-formatting/205084/8 "2026-01-12T17:32:17Z")

</div>

Cerrado el 12 Enero, 2026 17:32 UTC

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