[n8n] HTTP Request + Anthropic Claude API: “messages: Input should be a valid list” - Need help with array parameter
Hey n8n Community!
I’ve been struggling with a persistent HTTP Request issue for hours and can’t seem to get it working. Maybe someone has an idea?
The Problem:
- HTTP Request to Anthropic Claude API (https://api.anthropic.com/v1/messages)
- Getting constant 400 error: “messages: Input should be a valid list”
- Claude expects messages as JSON array, but n8n sends it as string
What I’ve already tried:
-
Body Content Type: JSON + “Using Fields Below”
messages: [{“role”: “user”, “content”: “test”}]
→ Result: String is sent, not array -
Body Content Type: Raw + application/json
{
“model”: “claude-3-5-sonnet-20241022”,
“messages”: [{“role”: “user”, “content”: “test”}]
}
→ Result: Same error -
Expression syntax attempted:
={{ [{“role”: “user”, “content”: “test”}] }}
→ Result: =[object Object] is displayed
Technical Details:
- n8n Version: Cloud (latest)
- Node Type: HTTP Request
- Authentication: Anthropic (working - other endpoints run fine)
- Content-Type: application/json
- anthropic-version: 2023-06-01
The core question:
How can I configure an HTTP Request in n8n so that messages is sent as a real JSON array (not string) to the API?
Additional question:
Is there a “JSON/RAW parameters” option in n8n that I’m missing? Or another way to send arrays correctly?
Has anyone successfully worked with the Anthropic Claude API through n8n? Any tip is welcome!
Thanks in advance!