// guides · n8n error index

n8n GraphQL node not working: variables, errors, 401, 34 runs

Fix the n8n GraphQL node: "Using variables failed", variables silently not sent with GET or Raw format, GraphQL errors failing the node, a green 401, "Response body is not valid JSON", and one item instead of many. 34 real runs on n8n 2.43.7.

Updated 2026-10-25 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. "Using variables failed": the variables are not valid JSON

    The Variables field must hold valid JSON. Single quotes, {'id': 5}, failed with Using variables failed ... Expected property name or '}' in JSON at position 1. An expression without quotes, {"name": {{ $json.name }} }, failed with Unexpected token 'A' because the text value landed in the JSON bare. Quoting it, "{{ $json.name }}", worked until a value contained a double quote, then failed with Expected ',' or '}' after property value. What worked every time: {{ JSON.stringify({ name: $json.name }) }}, or an object expression like {{ { name: $json.name, id: $json.id } }}. See n8n expression errors.

  2. Variables are silently not sent: GET and Raw format

    With Request Method GET, n8n put the query in ?query= and did not send the variables you typed, with no warning. With Request Format GraphQL (Raw), the body was only the query text and the variables were dropped. Version 1 of the node defaults to Raw, so older workflows can lose variables without any error; version 1.1 defaults to JSON. Use POST and Request Format JSON. Overriding the Content-Type header to application/json on Raw format does not fix it: the body went out as a JSON string, not an object.

  3. GraphQL errors fail the node, even with partial data

    When the server replied with an errors array, on HTTP 200 or 400, the node failed with the first message, for example Cannot query field "foo" on type "Query". A plain string in errors became the message too (Rate limit exceeded). When the reply had partial data plus errors, the node still failed and the partial data was lost. With On Error set to Continue (regular output) it went green but produced two items: the full response and {"error": "..."}. Filter on $json.error afterwards, or downstream nodes run twice. One failing item also stopped every item: 3 inputs with an error on the second gave no output at all.

  4. A 401 or 404 shows up as a green success

    The GraphQL node does not fail on HTTP status codes when the reply is JSON. A 401 with {"message":"Bad credentials"} came out green as the output item, and so did a 404. A token sent without the Bearer prefix gave exactly that green 401; adding Bearer returned the data. Add an IF or Filter after the node that checks $json.data exists, and see n8n HTTP Request errors for 401 and 403 causes.

  5. "Response body is not valid JSON. Change Response Format to String"

    When the server answered with an HTML error page or plain text, for example a login page on 401 or a proxy's 500, the node failed with Response body is not valid JSON. Change "Response Format" to "String", which hides the real status. Set Response Format to String: the run went green and the raw body showed up in the field data (or the field you set in Put Output In Field), so you can read what the server really said.

  6. One item with a list instead of one item per result

    A reply with data.users holding 3 users came out as one item with the array inside, so the next node ran once. Add a Split Out node on data.users to get one item per user; see n8n Split Out not working. Only a reply that is a top-level JSON array was split into items automatically. The node also runs once per input item: 3 items sent 3 requests, each with its own variables. For cursor pagination, see n8n pagination not working (not tested with the GraphQL node).

  7. Connection refused and required fields

    With the server down, the node failed with The service refused the connection - perhaps it is offline. With Endpoint or Query empty, the workflow did not start at all: Parameter "Endpoint" is required. or Parameter "Query" is required.

What we ran

On 25 October 2026 we ran 34 executions of the GraphQL node (v1.1, one run on v1) on self-hosted n8n 2.43.7 with n8n execute. The endpoint was a local mock GraphQL server we wrote, which recorded exactly what n8n sent and returned fixed GraphQL-shaped replies. So what n8n sends and how it handles each reply is real, but the replies are our test fixtures, not GitHub, Shopify or another real API. Fixes marked "not tested" are suggestions we did not run.

What we ranWhat happened
Variables with single quotes {'id': 5}Fail: Using variables failed ... Expected property name or '}' in JSON at position 1
Variables {"name": {{ $json.name }} }, text valueFail: Using variables failed ... Unexpected token 'A'
Variables {"name": "{{ $json.name }}" }OK
Same, value contains a double quoteFail: Expected ',' or '}' after property value
Variables {{ JSON.stringify({ name: $json.name }) }}OK, quote escaped
Variables as an object expression {{ { name: $json.name, id: $json.id } }}OK
Variables emptyOK, sent "variables": {}, "operationName": null
Operation Name setSent only when set
Request Method GETQuery in ?query=, variables NOT sent
Request Format GraphQL (Raw)Body is the query text only, variables dropped
Node v1 with default settingsRaw format, variables dropped
Raw format + header Content-Type: application/jsonBody sent as a JSON string, not an object
Server replies 200 with errorsFail: first error message, e.g. Cannot query field "foo" on type "Query".
Server replies 400 with errorsFail, same message
errors is a plain stringFail: Rate limit exceeded
Partial data plus errorsFail, partial data not kept
Same with On Error = ContinueGreen, 2 items: full response and {"error": "..."}
3 items, the 2nd gets errorsExecution error, no output for any item
HTTP 401 JSON {"message":"Bad credentials"}Green, that JSON is the output
Token without Bearer Green 401 output
Token with Bearer Green, real data
HTTP 404 JSONGreen {"message":"not found"}
HTML 401 pageFail: Response body is not valid JSON. Change "Response Format" to "String"
Text 500 replyFail, same message
Either one with Response Format StringGreen, body in field data
Reply data.users with 3 usersOne item holding the array
Reply is a top-level JSON arrayOne item per element
3 input items3 requests, each with its own variables
Server downThe service refused the connection - perhaps it is offline
Endpoint emptyWorkflow will not start: Parameter "Endpoint" is required.
Query emptyWorkflow will not start: Parameter "Query" is required.

Checklist

What we did not test

Real public GraphQL APIs, Header Auth and OAuth2 credential types, introspection, cursor pagination, file uploads, subscriptions, self-signed certificates, n8n Cloud and the editor UI.

FAQ

Why does the n8n GraphQL node say "Using variables failed"?

The Variables field is not valid JSON, usually single quotes or an expression value without quotes. Use {{ JSON.stringify({ ... }) }} or an object expression instead of building JSON by hand.

Why are my GraphQL variables not sent from n8n?

GET and the GraphQL (Raw) request format do not send variables, and node version 1 defaults to Raw. Use POST with Request Format JSON.

Why does the GraphQL node fail when the API returned data?

If the reply has an errors array, n8n fails the node with the first message and drops any partial data. On Error Continue keeps the response but adds an extra error item.

Why is a 401 from my GraphQL API green in n8n?

The node does not fail on HTTP status when the reply is JSON. Check that $json.data exists after the node, and add the Bearer prefix to the token.

How do I fix "Response body is not valid JSON" in the GraphQL node?

The server sent HTML or text, often an error page. Set Response Format to String to see the body and the real error.

How do I get one item per result from the GraphQL node?

The node returns one item with the list inside data. Add a Split Out node on the list field, for example data.users.

Related guides

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.