问题
We've recently seen what we believe is a change of functionality regarding the use of the top and skip query parameters when making a /drives call.
An example call is:
https://graph.microsoft.com/v1.0/sites/{siteid}/drives?top=1&skip=2
This results in the error message:
{
"error": {
"code": "invalidRequest",
"message": "$skip is not supported on this API. Only URLs returned by the API can be used to page.",
"innerError": {
"request-id": "14be8885-c3ba-48cc-862b-169dc2c02792",
"date": "2017-08-22T21:15:44"
}
}
}
We are trying to get a list of document libraries for a site collection. We would like to be able to page through them. Is this not the correct approach?
I understand that the concept of skipToken exists but do not receive one when limiting this call with the top query param.
https://graph.microsoft.com/v1.0/sites/muskpartners.sharepoint.com,d0e2f49b-e44c-43a6-8011-c00515666077,05e55f15-4584-4e3d-bf5c-dd4164b76685/drives
returns 3 items:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
"value": [
{
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"createdDateTime": "2017-07-25T05:42:33Z",
"description": "This library contains administrator-approved form templates that were activated to this site collection.",
"id": "b!m_Ti0EzkpkOAEcAFFWZgdxVf5QWERT1Ov1zdQWS3ZoWizkgpZiHkQpkllC4-bnhA",
"lastModifiedDateTime": "2017-07-25T05:42:33Z",
"name": "Form Templates",
"webUrl": "https://muskpartners.sharepoint.com/portals/Community/FormServerTemplates",
"driveType": "documentLibrary",
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
},
{
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"createdDateTime": "2017-07-25T05:41:53Z",
"description": "This system library was created by the PointPublishing feature to store stories that are used throughout the site collection.",
"id": "b!m_Ti0EzkpkOAEcAFFWZgdxVf5QWERT1Ov1zdQWS3ZoVz8ZvkSRbdTYvi75sQq3Tt",
"lastModifiedDateTime": "2017-07-25T05:41:53Z",
"name": "Pages",
"webUrl": "https://muskpartners.sharepoint.com/portals/Community/pPg",
"driveType": "documentLibrary",
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
},
{
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"createdDateTime": "2017-07-25T05:41:59Z",
"description": "This system library was created by the PointPublishing feature to store settings that are used throughout the site collection.",
"id": "b!m_Ti0EzkpkOAEcAFFWZgdxVf5QWERT1Ov1zdQWS3ZoU_AWZq16MrSLjg0Cv0MA8_",
"lastModifiedDateTime": "2017-07-25T05:41:59Z",
"name": "Settings",
"webUrl": "https://muskpartners.sharepoint.com/portals/Community/pSet",
"driveType": "documentLibrary",
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
},
{
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"createdDateTime": "2017-07-25T05:41:43Z",
"description": "Use the style library to store style sheets, such as CSS or XSL files. The style sheets in this gallery can be used by this site or any of its subsites.",
"id": "b!m_Ti0EzkpkOAEcAFFWZgdxVf5QWERT1Ov1zdQWS3ZoUmZuKEP6ZjQ75eVvVinqIN",
"lastModifiedDateTime": "2017-07-25T05:41:47Z",
"name": "Style Library",
"webUrl": "https://muskpartners.sharepoint.com/portals/Community/Style%20Library",
"driveType": "documentLibrary",
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
}
]
}
When I use the top query param such as:
https://graph.microsoft.com/v1.0/sites/muskpartners.sharepoint.com,d0e2f49b-e44c-43a6-8011-c00515666077,05e55f15-4584-4e3d-bf5c-dd4164b76685/drives?top=1
I receive only one result and no way to page to the others.
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
"value": [
{
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"createdDateTime": "2017-07-25T05:42:33Z",
"description": "This library contains administrator-approved form templates that were activated to this site collection.",
"id": "b!m_Ti0EzkpkOAEcAFFWZgdxVf5QWERT1Ov1zdQWS3ZoWizkgpZiHkQpkllC4-bnhA",
"lastModifiedDateTime": "2017-07-25T05:42:33Z",
"name": "Form Templates",
"webUrl": "https://muskpartners.sharepoint.com/portals/Community/FormServerTemplates",
"driveType": "documentLibrary",
"quota": {
"deleted": 0,
"remaining": 0,
"total": 0,
"used": 0
}
}
]
}
If the skipToken is what I should be looking for, is it a bug that it is not returned in this case?
回答1:
Not all ODATA parameters are supported by all endpoints, the /drives endpoint for example doesn't support the $skip parameter. What you're looking for instead is the $skipToken.
The $top parameter sets the page size. If you're call to the API has additional results (i.e. more drives in this case) then the results will include a skipToken value. Passing that token into the API will fetch the next page of results (and another skipToken if there are yest more data).
https://graph.microsoft.com/v1.0/sites/{siteId}/drives?$top=1&$skiptoken={skipToken}
You can read about using this parameter under Paging Microsoft Graph data in your app.
来源:https://stackoverflow.com/questions/45827223/unable-to-use-both-top-and-skip-on-drives-request-for-the-office-365-graph-api