Mary
Mary

Reputation: 20495

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 (e.g. 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?

Upvotes: 5

Views: 6116

Answers (1)

Tanaike
Tanaike

Reputation: 201553

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.

Upvotes: 6

Related Questions