Google Document AI HTTP Request node fails with Base64 decoding error on Form binary output

Hi community, I’m using an HTTP Request node to post a base64 encoded document to Google Document AI (process endpoint) coming from an n8n Form Trigger.

Input Binary Key: Upload_Identity_Document__CNIE__Residence_Permit__or_Passport_

Payload format used in HTTP Request Node (Using JSON):

JSON

{
  "rawDocument": {
    "mimeType": "={{ $binary['Upload_Identity_Document__CNIE__Residence_Permit__or_Passport_'].mimeType }}",
    "content": "={{ $binary['Upload_Identity_Document__CNIE__Residence_Permit__or_Passport_'].data }}"
  }
}

Error Received: Bad request - please check your parameters: Invalid value at 'raw_document.content' {TYPE_BYTES}, Base64 decoding failed for "={{ $binary... }}"

How can I properly pass the Base64 binary string from a Form trigger directly into the raw JSON body without n8n treating the expression as a literal string or returning undefined?

Hey @Samir_Dioua, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@achamm, @Pedro_Souss, @Sudhanshu_Sharma - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

Hi @Samir_Dioua Welcome!
The error quotes your expression back verbatim, so the JSON body field is still in fixed mode and the = prefixes are going out as literal text. That = is the marker n8n writes internally once a field is switched to an expression, typing it into a fixed field does not switch it.
The binary also needs its own step. On n8n 2.x binary data lives in the filesystem or the database rather than inside the item, so $binary.<key>.data is a reference rather than the base64 string. Put an Extract from File node between the form trigger and the HTTP Request, set Operation to “Move File to Base64 String”, Input Binary Field to Upload_Identity_Document__CNIE__Residence_Permit__or_Passport_, and Destination Output Field to data.
Then switch the HTTP Request JSON body itself to expression mode and drop the inner = signs:

{
  "rawDocument": {
    "mimeType": "{{ $('On form submission').item.binary.Upload_Identity_Document__CNIE__Residence_Permit__or_Passport_.mimeType }}",
    "content": "{{ $json.data }}"
  }
}

Change the node name in the mimeType line if your form trigger is named differently.