# OpenAI HTTP (legacy) 400 “We could not parse the JSON body” — Make mapping tokens causing invalid JSON?

**URL:** <https://community.make.com/t/openai-http-legacy-400-we-could-not-parse-the-json-body-make-mapping-tokens-causing-invalid-json/101873>\
**Category:** Questions\
**Tags:** http, ai\
**Created:** [January 24, 2026, 9:44pm UTC](https://community.make.com/t/openai-http-legacy-400-we-could-not-parse-the-json-body-make-mapping-tokens-causing-invalid-json/101873 "2026-01-24T21:44:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Ward](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Scott\_Ward](https://community.make.com/u/Scott_Ward)\
**Post date:** [January 24, 2026, 9:44pm UTC](https://community.make.com/t/openai-http-legacy-400-we-could-not-parse-the-json-body-make-mapping-tokens-causing-invalid-json/101873/1 "2026-01-24T21:44:03Z")

</div>

### 🎯 What is your goal?

1. I receive a Mindee response (module 29) containing a transactions array:  
29.data.inference.result.fields.transactions
2. I set a variable (Tools → Set variable) called transactions\_json using:  
toJSON(29.data.inference.result.fields.transactions)
3. I pass that into my OpenAI request content inside messages.

### 🤔 What is the problem & what have you tried?

As soon as I map the Make variable into the JSON request body, the OpenAI request fails with “invalid JSON”.  
Request content currently looks like this in Make (simplified):  
{  
“model”: “gpt-4.1-mini”,  
“temperature”: 0,  
“response\_format”: { “type”: “json\_object” },  
“messages”: [  
{ “role”: “system”, “content”: “…” },  
{ “role”: “user”, “content”: “…” },  
{ “role”: “user”, “content”: “TRANSACTIONS\_JSON:\n\<Make mapped variable: 48.transactions\_json\>” }  
]  
}

What’s the correct way in Make to embed a mapped JSON string / array into an HTTP Raw JSON body so the final payload remains valid JSON?  
Do I need to:  
escape quotes/newlines differently?  
use a different module (HTTP v2 / OpenAI module)?  
build the body with Create JSON / Compose a JSON first rather than Raw?  
or use parseJSON() + send it as an actual array (not a string)?  
If helpful, I can paste the exact “Input” payload Make shows under the module run.

### 📋 Error messages or input/output bundles

Screenshot 2026-01-24 at 21.38.48

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [January 25, 2026, 4:09am UTC](https://community.make.com/t/openai-http-legacy-400-we-could-not-parse-the-json-body-make-mapping-tokens-causing-invalid-json/101873/3 "2026-01-25T04:09:46Z")

</div>

Welcome to the Make community!

## Modules Using _Raw_ JSON

The **HTTP “Make a request”** or an app’s universal **“Make an API call”** modules uses raw JSON to transmit data. The HTTP body content field does not automatically escape variables mapped into it, and if the mapped variables contain JSON reserved characters (e.g. from the output of an AI module, or another JSON string), it breaks the structure of your outermost JSON.

**Simple text string in the value is okay** ✅

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/c/b/cb015cd1e514c1190408e52a837b8fbfa576945d.png)

**Inserting special characters (like `"` and _line-breaks_), makes the JSON invalid.** ❌

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/1/c/1cfc4e6de637d982ed62dca4223ec15b23be1380.png)

**Correctly escaped special JSON characters in the value** ✅

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/7/b/7b7400c1cb81d358a2fcb4aa85e9b8239e4bf4a6.png)

## Escaping Variables Before Mapping Into Another JSON (string)

Most of the time, you cannot directly map variables containing text content into another JSON string without _escaping_ them, as the variable might contain special characters that are reserved. Special characters in JSON needs to be escaped (encoded) as a “literal” character, otherwise they make the whole JSON invalid when you map the variable value when creating another JSON string.

### A. Using “Transform to JSON” Module

You can escape variables by passing the text into the “ **Transform to JSON** ” module. You can also build a valid JSON string by using a Data Structure with the “ **Create JSON** ” module. Then, you can map the output of the Transform module into another JSON, or simply use the whole output of the Create module.

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/a/a/aa0ef208a28e27eeefcf011325a0b0e6123e626e.png)

> ## ⚠ Note:
> 
> When using the “Transform to JSON” module on a _string_-type variable, the output should already contain the double quotes `" "` around your text, so when you map this output into your JSON, **do not wrap another pair of double quotes** around it!
> 
> ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/c/b/cb85a3fc88e09bb22f393222fdaf020b27da17a6.png)

### B. Using “Replace” Function

Alternatively, you can use the built-in function `replace` to replace those special characters with their escaped versions. To do this, simply paste this into the field, and replace the `1.text` variable:

> `{{ replace(replace(1.text; "/([""\\])/g"; "\$1"); "/\r?\n\r?/g"; "\n") }}`  
> ⚡ _ **Make Input Markup:** Copy-paste the above into the field, including start/end curly brackets for it to import as intended_ ⚠

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/7/1/71c9df63363dbdd0f0170b6b5abd99e17ff03a72.png)

## Further Information

For more information on JSON and escaping special characters, see:

- [JSON - Wikipedia](https://en.wikipedia.org/wiki/JSON)
- [JSON - Glossary | MDN](https://developer.mozilla.org/en-US/docs/Glossary/JSON)
- [Introducing JSON](https://www.json.org/json-en.html)
- [How to escape special characters in building a JSON string?](https://stackoverflow.com/q/19176024/584192)

Hope this helps! If you are still having trouble, please [provide more details](https://community.make.com/t/mastering-the-make-community-get-started/11682).

— @samliew

---

<div class="post-metadata">

**Author:** ![Scott\_Ward](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Scott\_Ward](https://community.make.com/u/Scott_Ward)\
**Post date:** [January 25, 2026, 12:41pm UTC](https://community.make.com/t/openai-http-legacy-400-we-could-not-parse-the-json-body-make-mapping-tokens-causing-invalid-json/101873/4 "2026-01-25T12:41:02Z")

</div>

> [@samliew](#):
>
> structure

Thank you Samliew, I really appreciate the effort you have gone to on this, I will give it a try, and let you know if any issues !

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [February 8, 2026, 4:57am UTC](https://community.make.com/t/openai-http-legacy-400-we-could-not-parse-the-json-body-make-mapping-tokens-causing-invalid-json/101873/5 "2026-02-08T04:57:04Z")

</div>


