How to send base64-encoded PDF file from Google Drive to HTTP Request node?

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.86.1
  • Database (default: SQLite): SQLite (default)
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own (default)
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: Windows 11

Hi, I’m trying to connect to an external API using the HTTP Request node in n8n.

Here’s my current workflow:

  • Google Drive Node

    • Operation: Download
    • Resource: File
  • HTTP Request Node

    • Method: POST
    • Content-Type: application/json

According to the API documentation, I need to send the PDF file as a base64-encoded string in the data field of the JSON body.

The Google Drive node successfully downloads the PDF file.
However, I’m not sure how to access the base64-encoded binary data of the file.

I read in the documentation that it might be accessible using binary.data.data,
but when I try that, I get an error saying the data doesn’t exist.

:red_question_mark: What’s the correct way to reference the base64 data from the Google Drive node
in the HTTP Request node?

Example payload I want to build:

{
  "data": ??? ← What expression should go here?
}

Try this:

{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "041b48ed-e174-42b8-8ffc-784abc022199",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "1mH8DmqcUAo_QABax_sB0_IM2dnUL26Q5",
          "mode": "list",
          "cachedResultName": "0aa3d1c7-2cad-461f-abba-371446687661.pdf",
          "cachedResultUrl": "https://drive.google.com/file/d/1mH8DmqcUAo_QABax_sB0_IM2dnUL26Q5/view?usp=drivesdk"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        208,
        0
      ],
      "id": "f85e06c2-a4b4-43ba-a5d1-6e641cfd834a",
      "name": "Download file",
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "6qPTH5ldV1hRKhEy",
          "name": "Google Drive Main account"
        }
      }
    },
    {
      "parameters": {
        "operation": "binaryToPropery",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        416,
        0
      ],
      "id": "f45a1c3e-1ddd-4b12-8321-873f108bbd14",
      "name": "Extract from File"
    }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download file": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "9423335a0111216c302866f5fc1752af6da6042c706e1cc46ecd439bca874130"
  }
}

This is how you can turn pdf binary to a base64 string.

Thank you! However, I have an additional question. When I ran an OCR on the extracted data, it seems that only one of the two PDF pages was OCRed. What could be the issue?

@skkustartup

If you could create an additional topic about this saparaate issue, that would be great; and for this one, if I was able to answer your question, kindly mark the answer as solution. Thank you.

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