Send document as pdf using Gmail

Hello,

I’m new here and also as an n8n user. Congratulations to the team for what they’ve built so far.

I want to send a document that is on Google Drive as a pdf using Gmail, I tried to use Drive’s download node, but I wasn’t successful. I’m using n8n with the npx command.

Displays ERROR: Forbidden - perhaps check your credentials?

Request failed with status code 403

{"message":"Request failed with status code 403","name":"Error","stack":"Error: Request failed with status code 403\n    at createError (C:\\Users\\Samsung\\AppData\\Roaming\\npm\\node_modules\\n8n\\node_modules\\axios\\lib\\core\\createError.js:16:15)\n    at settle (C:\\Users\\Samsung\\AppData\\Roaming\\npm\\node_modules\\n8n\\node_modules\\axios\\lib\\core\\settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (C:\\Users\\Samsung\\AppData\\Roaming\\npm\\node_modules\\n8n\\node_modules\\axios\\lib\\adapters\\http.js:269:11)\n    at IncomingMessage.emit (node:events:402:35)\n    at endReadableNT (node:internal/streams/readable:1343:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)"}

This is my workflow

Could you help me with this?

Thanks,

Claudio Balbino

Hi @Claudio_Balbino, welcome to the community and thanks so much for reaching out!

A 403 status would indicate a permissions problem as per Google’s docs, which includes rate limiting problems. Is your initial Google Sheets node returning multiple items and do individual operations work using your Google Drive credentials (e.g. if you run a simple workflow consisting of one node downloading one file, would this work for you)?

If so, you might have hit this Google Drive API write limit:

The rate of Drive API write requests is limited—avoid exceeding 3 requests per second of sustained write or insert requests, per account. Note: This rate limit can’t be increased.

Hi @MutedJam

I’m not sure I understand correctly, but in this example my spreadsheet has only one line… to test I eliminated some node from the drive and the problem persists

Is it related to me using npx locally?

{"message":"Request failed with status code 403","name":"Error","stack":"Error: Request failed with status code 403\n    at createError (C:\\Users\\Samsung\\AppData\\Roaming\\npm\\node_modules\\n8n\\node_modules\\axios\\lib\\core\\createError.js:16:15)\n    at settle (C:\\Users\\Samsung\\AppData\\Roaming\\npm\\node_modules\\n8n\\node_modules\\axios\\lib\\core\\settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (C:\\Users\\Samsung\\AppData\\Roaming\\npm\\node_modules\\n8n\\node_modules\\axios\\lib\\adapters\\http.js:269:11)\n    at IncomingMessage.emit (node:events:402:35)\n    at endReadableNT (node:internal/streams/readable:1343:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)"}

Do you have access to the drive/folder, you are trying to upload data to?

I would isolate the drive node and upload a file to a folder before adding it to any workflow. That way, you discard any issues related to permissions/credentials.

Thanks a lot for confirming @Claudio_Balbino and for chipping in @RicardoE105!

I quickly tried this on my end using npx and could indeed reproduce the problem when trying to download a Google Docs file. Even with a simple workflow like this:

This is working fine for other file types though, the only difference would be the File Id in this case:

Could this be because Google does not allow downloading Google Docs files directly (only in converted formats like MS Word) @RicardoE105? As per this doc:

Note: The only way to download a Google Workspace file is to export and download the file in a different file format.

@MutedJam

How do i transform this google docs into pdf to use the downlod node?

As @MutedJam explained, looks like for Google native files you need to export to a different mime-type in order to ‘download’ the file.

Right now, Google drive api does not support content downloading for native google drive files (google docs, sheets etc.), so you cant download content (current or of an old revision), you can only export it to a different mime type.

We need to add the export functionality to the node.

1 Like

I am afraid that’s an operation not currently supported by the Google Drive node.

In case it doesn’t have to be the specific Google Docs file you want to create the PDF file from, you could alternatively use a specialized service to create PDFs. For example Anvil (which you could connect to using our HTTP Request node) or APITemplate.io (which has its own node).

These services essentially create PDF documents for you based on the payload they receive.

Got added. We will let you know when it’s released.

3 Likes

@MutedJam and @RicardoE105

Thank you very much for your quick feedback and attention.

While we don’t have a solution with Google, I’m using the APITemplate

1 Like

Glad to hear this approach is working out for you for now!

I have also tested the enhanced Google Drive node developed by @RicardoE105 already and it’s working great with Google Docs files (including exporting them as PDF). So not much longer before your original approach would work too :slight_smile:

Many thanks for bringing this up!

2 Likes

what good news! :partying_face: :rocket:

@MutedJam and @RicardoE105, Hey! Now I’m looking for a solution to download Google Documents in pdf format. Tell me, is this already deployed in the latest version? I have upgraded to version 0.147.1 and am getting the following error:

Perhaps I am configuring something incorrectly in the node properties?

It does not work because it has not been merged yet. We will notify here when we do.

1 Like

@RicardoE105 , thanks!

@RicardoE105, Hey! Any news on this feature (exporting files to other formats in the Google Drive node)?

It’s still in the review column. Let me try to move it forward internally.

2 Likes

@RicardoE105 , Hey!
Is there a timeline for the implementation of this functionality? This can be very important for my project). Thanks in advance for your feedback!

Hi @RicardoE105

Any news about the implementation of this functionality?

1 Like