简体   繁体   中英

How to set the `fields` parameter in the Google Drive GoogleAPIs v3 in Dart?

I'm trying to return back a specific set of fields for the File resource from the Google Drive API , v3, for Dart. As specified , the regular list() call returns back just 4 params, but if I pass in the query param for fields (eg fields='starred,webContentLink' ), I can return back other information about the File. Likewise, passing in fields='*' returns back the entire File resource. This works fine in the 'Try this API' section of the documentation.

Right now, with the Dart package, setting $fields: '*' works, but setting $fields: 'starred' results in this error: DetailedApiRequestError(status: 400, message: Invalid field selection starred) .

// Assume I have successfully created an API client
g_drive.DriveApi api = new g_drive.DriveApi(client);
// This works
g_drive.FileList fileList = await api.files.list($fields: '*');
// This returns the 400 error
g_drive.FileList fileList = await api.files.list($fields: 'starred');

I went into the actual v3 code and manually changed _queryParams["fields"] to starred , but that didn't work either ( * works). I even tried 'starred' with the extra quotes just in case, but that resulted in the same error ( DetailedApiRequestError(status: 400, message: Invalid field selection 'starred') )

Is there something obvious I'm missing?

How about the following modification?

From :

$fields: 'starred'

To :

$fields: 'files/starred'

or

$fields: 'files%2Fstarred'

If you want to retrieve a list with starred and filename, you can use $fields: 'files(name,starred)' or $fields: 'files(name%2Cstarred)' .

Reference :

If this was not useful for you, I'm sorry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM