Binary becomes undefined after Switch/Merge - HTTP Request cannot send PDF (form-data)

Hi n8n community,
I’m on n8n 2.8.3 self-hosted with binaryDataMode=filesystem.
Download a PDF from Google Drive, detect if it’s scanned, then send the PDF to an external OCR endpoint using HTTP Request.

Describe the problem/error/question

In the HTTP Request node, $binary.data.data becomes undefined (or the API responds like “document has no pages”), even though the previous node shows the binary exists. Also, expressions in the JSON body don’t seem to “see” $binary.
Workflow path (node names):
[GDrive Download PDF] → [Code JS Detect scan] → [HTTP Request]
(There is also a [Switch Router de extracción] earlier in the flow.)
Binary structure at the input of HTTP Request (Binary tab):
binary.data contains mimeType, fileName, data (base64).
HTTP Request config:
Body Content Type: Form-Data
Field type: n8n Binary File
Input Data Field Name: data

What is the error message (if any)?

Please share your workflow

Information on your n8n setup

  • n8n version: 2.8.3
  • Database (default: SQLite): postgress in VPS
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker en easyPanel

The error shown is invalid syntax, so remove the = from the beginning of the expression,

After that, to get the Base64 string you can use the Extract from File node to extract it and include it in the JSON, if that’s what you’re trying to do.

From the screenshots, it looks like you’re trying to analyze some PDFs with Gemini,
FYI, the native Gemini node can do this easily:

2 Likes

Looking at your screenshots the issue is the ={{ at the start of your JSON expression, you need to remove that leading = like mohamed3nan mentioned. But honestly for sending PDFs to Gemini you’re overcomplicating this, the native Google Gemini Chat Model node handles document analysis directly without needing to manually construct the API payload with base64 encoding and all that. If you really need the HTTP Request approach for some reason, after fixing the syntax you’ll want to use the Extract from File node to get the base64 string properly, but I’d just switch to the Gemini node and save yourself the headache.

Thank you so much for your help, in the end I decided on the Gemini native node

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.