“Unexpected value type in payload”: Debugging Amazon Bedrock + n8n (with Claude 3.5)
Recently I wired up an evaluation pipeline in n8n using Amazon Bedrock (Anthropic Claude 3.5 Sonnet).
The goal was simple:
-
Upload a consulting slide deck (PDF)
-
Extract the text
-
Send it to Bedrock to score the deck against a rubric
-
Store the scores + human ratings in Airtable for comparison
Everything worked… until I replaced my tiny “hello” prompt with a real multi-line rubric. Then Bedrock started returning:
Bad request - please check your parameters
Unexpected value type in payload
If you’re trying to call Bedrock from n8n and keep hitting this error, this post walks through:
-
What causes it (in a very real, painful example)
-
How to structure the messages payload correctly
-
How to handle multi-line prompts and large text (like PDF content)
-
How to avoid n8n JSON pitfalls
The working baseline: a tiny prompt
In n8n, I used an HTTP Request node pointing to Bedrock’s invoke endpoint, with a minimal body like this:
{
"messages": [
{
"role": "user",
"content": [
{ "text": "Say hello Claude 4.5 Sonnet." }
]
}
],
"inferenceConfig": {
"maxTokens": 1500
}
}
-
Method:
POST -
Content-Type:
application/json -
Body: JSON mode in n8n
This worked perfectly. Bedrock replied with a nice “hello”.
So far so good.
When everything broke: adding the real rubric
Next I swapped the tiny prompt for a big evaluation rubric: scoring clear objective, logical flow, visual design, etc.
I pasted something like this inside "text": "...":
You are an expert evaluator of consulting presentation decks...
------------------------------------
OUTPUT FORMAT (STRICT JSON)
------------------------------------
Return ONLY the following JSON:
{
"Clear Objective": { "score": 0.0|0.5|1.0, "justification": "...", "evidence": "..." },
"Logical Flow": { "score": 0.0|0.5|1.0, "justification": "...", "evidence": "..." },
...
"Total Score": <sum of all scores>,
"Summary": "<2–3 sentence high-level summary of the deck’s quality>"
}
Same structure, just a bigger prompt.
Suddenly Bedrock started throwing:
Unexpected value type in payload
Changing the model, reducing maxTokens, etc. didn’t help. But a one-line prompt still worked.
So what was going on?
Root cause #1: invalid JSON inside your JSON
The key mistake: I dropped a JSON example inside the "text" string without escaping anything.
From Bedrock’s perspective, the body looked roughly like:
{
"messages": [
{
"role": "user",
"content": [
{
"text": "Return ONLY the following JSON:
{
"Clear Objective": { "score": 0.0|0.5|1.0, "justification": "...", "evidence": "..." },
...
}"
}
]
}
]
}
Notice the problem:
-
Inside the
"text"value, there are unescaped double quotes ("Clear Objective","score", etc.) -
That breaks the outer JSON. n8n sends malformed JSON → Bedrock says “unexpected value type”.
How to fix it
You have three options:
-
Don’t embed JSON at all.
Describe the structure instead:Return a JSON object with the following keys:
-
"Clear Objective"with fields"score","justification","evidence" -
"Logical Flow"with fields"score","justification","evidence"
…
-
-
Use single quotes inside the example and keep double quotes only for the outer JSON string (less strict but often enough).
-
Properly escape the inner quotes (e.g.,
\"Clear Objective\") – but this gets messy fast, especially in n8n’s JSON editor.
In practice, option 1 is the cleanest: describe the JSON rather than pasting a raw JSON template.
Root cause #2: multi-line prompts in n8n’s JSON editor
The other thing that confused me: when I had a long, multi-line prompt, errors became harder to reason about.
The trick that made everything stable:
Build the prompt in a Code node and send it as data, not as raw JSON text
Instead of fighting with huge strings in the HTTP node, I switched to this pattern:
-
Extract PDF text (via the Extract from File node).
-
In a Code (JavaScript) node, build a clean prompt:
const deckText = $item(0).$node["Extract from File"].json.text; const rubricPrompt = `
You are an expert evaluator of consulting presentation decks…
SCORING RULES
1.0 = Outstanding …
0.5 = Basic …
0.0 = Poor …
EVALUATION CRITERIA
-
Clear Objective — …
-
Logical Flow — …
…
DECK TEXT TO EVALUATE
${deckText}
`.trim();
return [
{
json: {
messages: [
{
role: “user”,
content: [
{ text: rubricPrompt }
]
}
],
inferenceConfig: {
maxTokens: 1500
}
}
}
];
3. In the **HTTP Request (Bedrock)** node:
- Body mode: **JSON**
- Click the little gear → **Add Expression**
- Use: `={{ $json }}` so the node sends exactly the object produced by the Code node.
Now:
- n8n never has to parse a giant JSON literal with embedded quotes.
- The prompt can have as many line breaks as you want.
- You can inject the deck text with `${deckText}` safely.
---
## Correct Bedrock payload structure (for Claude 3.5 via n8n)
This is the structure that works reliably:
```json
{
"messages": [
{
"role": "user",
"content": [
{ "text": "full prompt including rubric and deck text..." }
]
}
],
"inferenceConfig": {
"maxTokens": 1500
}
}
Key things to watch:
-
messagesis an array -
Each message has a role (
"user","assistant", etc.) -
contentis an array of objects, each with"text"
(Bedrock’s API wrapper handles thetype: "text"part under the hood) -
No extra wrapper JSON like
"anthropic_version"if you’re using the Bedrock runtime style you get from the console’s Test feature.