1
votes

It looks like the OData $count parameter is not (yet?) supported in the Microsoft Graph API v1.0 for OneDrive.

Request URL: https://graph.microsoft.com/v1.0/me/drive/root/children?$count=true

Response:

{
  "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": "e65aff74-1c6f-434b-8cd3-04e0c247fb71",
      "date": "2016-10-19T09:48:39"
    }
  }
}

Is this understanding correct?

1

1 Answers

2
votes

The $count parameter isn't supported with OneDrive. You can get a count of the children however by moving one level up:

/v1.0/me/drive/root/

This includes a folder property that contains the number of child items:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('id')/drive/root/$entity",
    "createdDateTime": "2012-08-03T08:12:58Z",
    "id": "{id}",
    "lastModifiedDateTime": "2016-10-18T14:19:21Z",
    "name": "root",
    "webUrl": "{webUrl}",
    "folder": {
        "childCount": 28
    },
    "root": {},
    "size": 0,
    "specialFolder": {
        "name": "documents"
    }
}