Sak*_*ket 6 office365 onedrive microsoft-graph
我正在尝试使用Microsoft OneDrive API/SDK实现客户端分页.为此,我需要项目的总计数作为API的响应,并且基于传递给API的跳过和最大限制值,应该获取响应.
在List Items链接中,提到我们可以使用此处提供的查询字符串来实现此目的.基于这个假设,我正在构建API调用的URL,如下所示:
string.Format("https://graph.microsoft.com/v1.0/me/drive/root/children?$skip={0}&$top={1}&$count=true",topValue*page, topValue)
Run Code Online (Sandbox Code Playgroud)
根据上面提到的URL中的信息,一切似乎都很好,但我从服务器收到"错误请求",并显示错误消息,如下所示:
{
"error": {
"code": "",
"message": "The query specified in the URI is not valid. Query option 'Skip' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings.",
"innerError": {
"request-id": "384693d7-65bd-4dc6-8d60-afde68e01555",
"date": "2017-04-25T10:28:15"
}
}
}
{
"error": {
"code": "",
"message": "The query specified in the URI is not valid. Query option 'Count' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings.",
"innerError": {
"request-id": "2188a06f-10cf-402c-9c49-bd296b9db614",
"date": "2017-04-25T10:29:05"
}
}
}
Run Code Online (Sandbox Code Playgroud)
这可以使用REST API或Microsoft Graph SDK实现吗?
PS:我看到了skipToken的概念,但是它不符合我们的要求,因为它不返回总计数,只支持增量导航.
看来 OneDrive 工程师已经在这里回答了这个问题:
OneDrive 的分页模型与skip+take 略有不同。本质上,您将进行如下查询:
获取https://graph.microsoft.com/v1.0/me/drive/root/children ?$top=5
在响应中,您应该看到通常的值数组,以及名为 @odata.nextLink 的属性。您需要使用该 URL 来请求下一页:
"@odata.nextLink": " https://graph.microsoft.com/v1.0/me/drive/root/children ?$skiptoken=ASDGASGSD"
获取 https://graph.microsoft.com/v1.0/me/drive/root/children ?$skiptoken=ASDGASGSD
您继续执行此操作,直到没有返回 @odata.nextLink。
| 归档时间: |
|
| 查看次数: |
483 次 |
| 最近记录: |