使用Google-Drive-API的文件导出时如何设置mimeType?

时间:2019-01-21 05:32:57

标签: python google-api google-drive-api google-api-python-client

我使用[google-drive-sdk],我了解如何导出文件here

我知道fileIdmimeType这两个项目是必需的。

当我将mimeType设置为application/vnd.google-apps.spreadsheet时,然后单击 按钮EXECUTE,响应为:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "The requested conversion is not supported.",
    "locationType": "parameter",
    "location": "convertTo"
   }
  ],
  "code": 400,
  "message": "The requested conversion is not supported."
 }
}

似乎我设置的mimeType错误,如何设置mimeType?

enter image description here

1 个答案:

答案 0 :(得分:0)

正如Tanaike所说,当我使用Files: export时,我将text/csv设置为mimeType时,响应没有错误。

现在您可以看到正确的答案:

enter image description here

实际上,使用Files: get可以获取详细的下载信息。 例如,在节点exportLinks中:

  

“ exportLinks”:{     “ application / x-vnd.oasis.opendocument.spreadsheet”:“ https://docs.google.com/spreadsheets/export?id=YpDWTfWh5VFtchFYA&exportFormat=ods”,     “ text / tab-separated-values”:“ https://docs.google.com/spreadsheets/export?id=YpDWTfWh5VFtchFYA&exportFormat=tsv”,     “ application / pdf”:“ https://docs.google.com/spreadsheets/export?id=YpDWTfWh5VFtchFYA&exportFormat=pdf”,     “ application / vnd.openxmlformats-officedocument.spreadsheetml.sheet”:“ https://docs.google.com/spreadsheets/export?id=YpDWTfWh5VFtchFYA&exportFormat=xlsx”,     “ text / csv”:“ https://docs.google.com/spreadsheets/export?id=YpDWTfWh5VFtchFYA&exportFormat=csv”,     “ application / zip”:“ https://docs.google.com/spreadsheets/export?id=YpDWTfWh5VFtchFYA&exportFormat=zip”,     “ application / vnd.oasis.opendocument.spreadsheet”:“ https://docs.google.com/spreadsheets/export?id=YpDWTfWh5VFtchFYA&exportFormat=ods”    }