How to upload "raw" files to to google drive?

Hi everyone,
I’m currently trying to upload an HTML document as a Google Doc into a Shared Drive using an HTTP Request node and a Google Service Account.
The service account has the correct permissions (Content Manager), and GET requests work fine, so access to the shared drive is confirmed.
However, I’m running into a strange issue with the multipart upload.
:check_mark: What works
If I don’t use the upload endpoint and instead call:
POST https://www.googleapis.com/drive/v3/files?supportsAllDrives=true
with a standard JSON body:
{
“name”: “test_doc”,
“mimeType”: “application/vnd.google-apps.document”,
“parents”: [“<MY_SHARED_DRIVE_FOLDER_ID>”]
}
→ The Google Doc is created successfully.
So the service account can definitely write to the shared drive.
:cross_mark: What does not work
When I use the actual upload endpoint:
POST https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&supportsAllDrives=true
using Raw multipart data, n8n produces inconsistent results:
Sometimes 403 – storageQuotaExceeded, even though it’s a shared drive
Sometimes Google creates a file named “Untitled” with MIME application/octet-stream
Sometimes the HTML part is ignored entirely
Here is the exact raw multipart body I am sending:
–foo_bar_baz
Content-Type: application/json; charset=UTF-8
{
“name”: “test_monatsbericht_html”,
“mimeType”: “application/vnd.google-apps.document”,
“parents”: [“<MY_SHARED_DRIVE_FOLDER_ID>”]
}
–foo_bar_baz
Content-Type: text/html; charset=UTF-8

Test

--foo_bar_baz-- Headers in n8n: Content-Type: multipart/related; boundary=foo_bar_baz Body settings: Send Body: On Body Content Type: Raw

Hey @ideka1111 !

Use Body Content Type: Form-Data and attach your HTML as an n8n Binary File parameter rather than raw multipart text, letting n8n generate the boundary and headers correctly…

Or use the build in node with proper configuration:

Google Drive → Create from text (+ Convert to Google Document) flow instead of manual multipart uploads.

Since you’re starting from HTML text and want a Google Doc in a Shared Drive, use Google’s import-from-text behavior via the Drive API, mapped to the n8n Google Drive → File → Create from text operation…

Here are the docs based for this:

So:

1 Google drive node Resource: File

  • Operation: Create from text

2 File Content: your HTML string (e.g. from a previous Code/AI node).

  • File Name: desired document name.

  • Parent Drive: your Shared Drive (by list/URL/ID).

  • Parent Folder: the target folder in that Shared Drive

3 In Options, enable Convert to Google Document so Drive converts the uploaded text into a Google Doc…

Hope this helps in some way!

Cheers!

Hey ithanks for the fat response. Im trying to do it via “Create from text” in the google drive node but the html formatting is not beings executed.

The Drive API requires an additional header, Content-Transfer-Encoding: binary, in the data part, even for simple text files like HTML…

can you try to add that line:

--foo_bar_baz
Content-Type: application/json; charset=UTF-8

{
  "name": "test_monatsbericht_html",
  "mimeType": "application/vnd.google-apps.document",
  "parents": ["<MY_SHARED_DRIVE_FOLDER_ID>"]
}

--foo_bar_baz
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: binary  <--  THIS LINE HEREE!!!

Test HTML Content Here
<p>Thi s is mi HTML document contennt ...</p>

--foo_bar_baz--

Here are the docs from Ggl devs :

2 Likes

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