简体   繁体   English

如何在Dart的Google Drive GoogleAPI v3中设置“ fields”参数?

[英]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. 我试图从Dart的Google Drive API v3返回文件资源的一组特定字段。 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. 指定的那样 ,常规list()调用仅返回4个参数,但是如果我传入字段的查询参数(例如, fields='starred,webContentLink' ),则可以返回有关File的其他信息。 Likewise, passing in fields='*' returns back the entire File resource. 同样,传递fields='*'将返回整个文件资源。 This works fine in the 'Try this API' section of the documentation. 在文档的“尝试使用此API”部分中,这可以正常工作。

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) . 现在,使用Dart程序包,设置$fields: '*'可行的,但是设置$fields: 'starred'导致以下错误: 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). 我进入了实际的v3代码,并手动将_queryParams["fields"]更改为已加starred ,但是这也不起作用( *起作用)。 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') ) 我什至尝试用多余的引号对'starred'进行加引号,以防万一,但这导致了相同的错误( 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)' . 如果要检索带有星号和文件名的列表,则可以使用$fields: 'files(name,starred)' $fields: 'files(name%2Cstarred)'$fields: 'files(name%2Cstarred)'

Reference : 参考:

If this was not useful for you, I'm sorry. 如果这对您没有用,对不起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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