搜索日历事件时,如何在 Microsoft Graph Search API 中移动到下一页结果?
How to move to next page of results in Microsoft Graph Search API when searching calendar events?
使用 Microsoft Graph API,您可以通过发出像 documented here 或这样的请求来搜索您的日历事件:
POST /v1.0/search/query HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer <token>
Content-Type: application/json
Content-Length: 174
{
"requests": [
{
"entityTypes": [
"event"
],
"query": {
"queryString": "test"
},
"from": 0,
"size": 50
}
]
}
因此,就我而言,对于搜索查询 test
,我有 200 多个事件(重复事件和单个事件),并且在我们发送给 Microsoft Graph 的请求有效负载中,我们有 size
参数,它基本上设置了此调用要返回的记录的限制。
所以,当我从上面发出请求时,我得到了这样的结果,但绝不会超过 25
个结果。不管我怎么修改size
参数,它总是returns25
个事件,虽然有几百个
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#search",
"value": [
{
"@odata.type": "#microsoft.graph.searchResponse",
"searchTerms": [
"contoso"
],
"hitsContainers": [
{
"@odata.type": "#microsoft.graph.searchHitsContainer",
"hits": [
{
"@odata.type": "#microsoft.graph.searchHit",
"hitId": "AAMkADEwODY2NzllLTQ3MmEtNGRlMC05ZTUyLTE4ZDRhYmU1ZGM3NABGAAAAAAA3+iYQBnJnQabRVDelNhnzBwAejhWkAOAxQ6M4c1c9NwfrAAAAAAENAAAejhWkAOAxQ6M4c1c9NwfrAABbUZLJAAA=",
"rank": 1,
"summary": "this is a testing nothing more",
"resource": {
"@odata.type": "#microsoft.graph.event",
"end": {
"dateTime": "2020-06-16T04:15:00Z",
"timeZone": "UTC"
},
"hasAttachments": false,
"iCalUId": "040000008200E00074C5B7101A82E008000000007093FDD79B3AD60100000000000000001000000036DAA2262EB4E04DA27DA77985FB8251",
"isAllDay": false,
"sensitivity": "Normal",
"start": {
"dateTime": "2020-06-16T03:30:00Z",
"timeZone": "UTC"
},
"subject": "testing testing 123",
"type": "Single"
}
}
],
"total": 25,
"moreResultsAvailable": true
}
]
}
]
}
此外,在响应中你得到标志 moreResultsAvailable
,在我的例子中是 true
,但除此之外,我找不到在结果页面之间遍历的方法,或者做某种分页。
我在这里或文档中缺少什么?
So, when I issue the request from above, I get something like this,
but never more than 25 results. No matter how I modify the size
parameter, it always returns 25 events, although there are hundreds.
The maximum results per page (size) is 25 for message and event.
对于分页,您只需要使用 from 属性 来指定页面的开始,例如下一页将是
{
"requests": [
{
"entityTypes": [
"event"
],
"query": {
"queryString": "test"
},
"from": 25,
"size": 25
}
]
}
使用 Microsoft Graph API,您可以通过发出像 documented here 或这样的请求来搜索您的日历事件:
POST /v1.0/search/query HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer <token>
Content-Type: application/json
Content-Length: 174
{
"requests": [
{
"entityTypes": [
"event"
],
"query": {
"queryString": "test"
},
"from": 0,
"size": 50
}
]
}
因此,就我而言,对于搜索查询 test
,我有 200 多个事件(重复事件和单个事件),并且在我们发送给 Microsoft Graph 的请求有效负载中,我们有 size
参数,它基本上设置了此调用要返回的记录的限制。
所以,当我从上面发出请求时,我得到了这样的结果,但绝不会超过 25
个结果。不管我怎么修改size
参数,它总是returns25
个事件,虽然有几百个
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#search",
"value": [
{
"@odata.type": "#microsoft.graph.searchResponse",
"searchTerms": [
"contoso"
],
"hitsContainers": [
{
"@odata.type": "#microsoft.graph.searchHitsContainer",
"hits": [
{
"@odata.type": "#microsoft.graph.searchHit",
"hitId": "AAMkADEwODY2NzllLTQ3MmEtNGRlMC05ZTUyLTE4ZDRhYmU1ZGM3NABGAAAAAAA3+iYQBnJnQabRVDelNhnzBwAejhWkAOAxQ6M4c1c9NwfrAAAAAAENAAAejhWkAOAxQ6M4c1c9NwfrAABbUZLJAAA=",
"rank": 1,
"summary": "this is a testing nothing more",
"resource": {
"@odata.type": "#microsoft.graph.event",
"end": {
"dateTime": "2020-06-16T04:15:00Z",
"timeZone": "UTC"
},
"hasAttachments": false,
"iCalUId": "040000008200E00074C5B7101A82E008000000007093FDD79B3AD60100000000000000001000000036DAA2262EB4E04DA27DA77985FB8251",
"isAllDay": false,
"sensitivity": "Normal",
"start": {
"dateTime": "2020-06-16T03:30:00Z",
"timeZone": "UTC"
},
"subject": "testing testing 123",
"type": "Single"
}
}
],
"total": 25,
"moreResultsAvailable": true
}
]
}
]
}
此外,在响应中你得到标志 moreResultsAvailable
,在我的例子中是 true
,但除此之外,我找不到在结果页面之间遍历的方法,或者做某种分页。
我在这里或文档中缺少什么?
So, when I issue the request from above, I get something like this, but never more than 25 results. No matter how I modify the size parameter, it always returns 25 events, although there are hundreds.
The maximum results per page (size) is 25 for message and event.
对于分页,您只需要使用 from 属性 来指定页面的开始,例如下一页将是
{
"requests": [
{
"entityTypes": [
"event"
],
"query": {
"queryString": "test"
},
"from": 25,
"size": 25
}
]
}