## TL;DR

Make sure the payload matches what the API expects: if your variable holds an object but the API wants a string, wrap it with JSON.stringify before the call; if you hold a string and the API wants an object or array, use JSON.parse first. Fixing the string/object mismatch is what makes the POST work.

## Fix

1. Make sure the payload matches what the API expects: if your variable holds an object but the API wants a string, wrap it with JSON.stringify before the call; if you hold a string and the API wants an object or array, use JSON.parse first.
   Expected: You get the expected result; the problem is gone.
2. Fixing the string/object mismatch is what makes the POST work.
   Expected: You get the expected result; the problem is gone.

## When to use

- You are setting up or using this Retool REST query feature.
- The symptom matches: variable in JSON API POST request is not working.

## When NOT to use

- Unrelated Retool REST query issues (different feature, different failure).
- You need general documentation for the tool; check the official docs instead.

## Compatibility

Reported against Retool REST query.

## Variant phrasings

### variable in JSON API POST request is not working

## Why it happens

Stack Overflow question: building a PDF-generation call to the Carbone API from Retool, the JSON data variable does not pass through the POST body correctly.

## Edge cases

- If your error message differs even slightly, this is probably a different issue; search the exact text.
- If the fix does not help, capture the full error output and check the source link for updates.