google / googleapis.dart

Repository for building the googleapis packages
https://pub.dev/packages/googleapis
BSD 3-Clause "New" or "Revised" License
393 stars 119 forks source link

DriveApi.files.export - DetailedApiRequestError(status: 403, message: Export requires alt=media to download the exported content.) #78

Open lngcyho opened 5 years ago

lngcyho commented 5 years ago

I tried fetching a spreadsheet from Google Docs, I got a result back indicating the following error:

E/flutter ( 9786): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: DetailedApiRequestError(status: 403, message: Export requires alt=media to download the exported content.) E/flutter ( 9786): #0 _validateResponse (package:_discoveryapis_commons/src/clients.dart:875:9) E/flutter ( 9786): E/flutter ( 9786): #1 ApiRequester.request (package:_discoveryapis_commons/src/clients.dart:69:22) E/flutter ( 9786):

Code below: clientViaServiceAccount(_credentials, _SCOPES).then((httpClient) { var driveApi = CustomDriveApi(httpClient); final spreadSheetId = ''; final mimeType = 'application/pdf'; driveApi.files .exportWithAlt(spreadSheetId, mimeType, alt: 'media') .then((document) => print(document)); });

Was playing around with the mimeTypes -(csv/text, applciation/pdf) image

jonasfj commented 5 years ago

It's possible that there is a bug in the generated code, maybe the generator has a bug, or the published discovery documents have a bug.

This does look like how I would use the API, but it's hard to tell..

Side note: Please use code fences for snippets: https://help.github.com/en/articles/creating-and-highlighting-code-blocks