Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting an error while Download Files using Drive API

I am trying to pass the Google Spreadsheet ID (Where the file is in Google Drive with Every one view option) to the Google Drive Export API and download the file to local directory. As I need to download the file as xls or xlsx. If I use mimeType as "application/vnd.google-apps.spreadsheet" and getting an error as "The requested conversion is not supported". Same error message would be return to execute the same API using Google's API Explorer window as well. If I change the mimeType as "text/csv" then its working fine. Please help me whats the wrong with the mimeType which I used in the below code.

  const drive = google.drive({version: 'v3', auth});
  const res =  drive.files.export({
     fileId: '1YHO6KuXuUdTQmUgPTJkYNiLrkQBWejDREZLEK62ZT_Q',
     mimeType: 'application/vnd.google-apps.spreadsheet',
     responseType: 'stream' });
like image 938
Sumathi Avatar asked Oct 21 '25 02:10

Sumathi


1 Answers

Replace application/vnd.google-apps.spreadsheet with application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. Works like a dream.

like image 117
Vidura Dantanarayana Avatar answered Oct 27 '25 05:10

Vidura Dantanarayana



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!