gpt4 book ai didi

office365 - 使用 Microsoft OneDrive API/SDK 的客户端分页

转载 作者:行者123 更新时间:2023-12-04 15:52:28 28 4
gpt4 key购买 nike

我正在尝试使用 Microsoft OneDrive API/SDK 实现客户端分页。为此,我需要项目的总数作为来自 API 的响应,并且基于传递给 API 的跳过和最大限制值,应该获取响应。

List Items链接,提到我们可以使用提供的查询字符串来实现这一点 here .基于这个假设,我正在为 API 调用构建 URL,如下所示:

string.Format("https://graph.microsoft.com/v1.0/me/drive/root/children?$skip={0}&$top={1}&$count=true",topValue*page, topValue)

根据上面提到的 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"
}
}
}

这可以使用 REST API 或 Microsoft Graph SDK 来实现吗?

PS:我看到了 skipToken 的概念,但它不符合我们的要求,因为它不返回总数并且只支持增量导航。

最佳答案

看来 OneDrive 工程师已经回答了这个问题 here :

OneDrive's paging model is a little different to skip+take. Essentially you'll make a query like:

GET https://graph.microsoft.com/v1.0/me/drive/root/children?$top=5

and in the response you should see the usual array of values, along with a property called @odata.nextLink. You'll want to take that URL use it request the next page:

"@odata.nextLink": "https://graph.microsoft.com/v1.0/me/drive/root/children?$skiptoken=ASDGASGSD"

GET https://graph.microsoft.com/v1.0/me/drive/root/children?$skiptoken=ASDGASGSD

You keep doing this until you don't get an @odata.nextLink returned.

关于office365 - 使用 Microsoft OneDrive API/SDK 的客户端分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43608542/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com