SharePoint Librarys: Graph API Get items

New Contributor

Hey,

i wanna list all the items that are in a SharePoint library which is the root library of a Teamsite.

 

In the Graph API documentation i have found the following to "List children of a driveItem". Which seems to be what i need.  I'm using the Graph Explorer v1.0, i get an empty value.

 

GET /drives/{drive-id}/items/{item-id}/children
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('[Redacted]')/items('[Redacted]')/children",
    "value": []
}

 

 

When getting the metadata of a drive (Get a DriveItem resource) I get the follwoing result. 

 

GET /drives/{drive-id}/items/{item-id}/
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('[Redacted]')/items/$entity",
    "createdDateTime": "2018-06-29T06:58:41Z",
    "id": "[Redacted]",
    "lastModifiedDateTime": "2021-02-01T11:44:01Z",
    "name": "root",
    "webUrl": "[Redacted]",
    "size": 14251577828,
    "parentReference": {
        "driveId": "[Redacted]",
        "driveType": "documentLibrary"
    },
    "fileSystemInfo": {
        "createdDateTime": "2018-06-29T06:58:41Z",
        "lastModifiedDateTime": "2021-02-01T11:44:01Z"
    },
    "folder": {
        "childCount": 17
    },
    "root": {}
}

 

 

So instead of the first result to be empty I'm expecting to get at least the 17 Children on the first level.

 

I'd really appreciate any pointers as to what I'm doing wrong.

Thanks

 

EDIT: 

I created a new Teamsite in that Tenant and got the same results.

/drives/[Drive-id-Redacted]/items/[item-id-redacted]/children
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('Redacted')/items('Redacted')/children",
"value": []
}

 

I also did the same exact steps on another Tenant. Were i got the expected results. Everything on the first level of the document library was returned (empty folders, folders with content & files).

 

GET drives/[drive-id-Redacted]/items/[item-id-Redacted]/children

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21AkpyLC5wkUKil3rDWQGKATkY1dsy_8VBn4bwuhbxbzG5iis7JuCiTYx7InpDx1E7')/items('0165NKSCF6Y2GOVW7725BZO354PWSELRRZ')/children",
    "value": [
        {
            "createdDateTime": "2021-02-01T08:07:32Z",
            "eTag": "\"{Redacted},1\"",
            "id": "Redacted",
            "lastModifiedDateTime": "2021-02-01T08:07:32Z",
            "name": "_Test_Folder",
            "webUrl": "https://Redacted.sharepoint.com/sites/PowerAppsFunktionen/Freigegebene%20Dokumente/_Test_Folder",
            "cTag": "\"c:{Redacted},0\"",
            "size": 0,
            "createdBy": {
                "user": {
                    "email": "mmuster@Redacted.com",
                    "id": "Redacted",
                    "displayName": "Max Muster"
                }
            },
            "lastModifiedBy": {
                "user": {
                    "email": "mmuster@Redacted.com",
                    "id": "Redacted",
                    "displayName": "Max Muster"
                }
            },
            "parentReference": {
                "driveId": "Redacted",
                "driveType": "documentLibrary",
                "id": "Redacted",
                "path": "/drives/Redacted/root:"
            },
            "fileSystemInfo": {
                "createdDateTime": "2021-02-01T08:07:32Z",
                "lastModifiedDateTime": "2021-02-01T08:07:32Z"
            },
            "folder": {
                "childCount": 0
            }
        },
        {
            "createdDateTime": "2021-01-14T08:14:40Z",
            "eTag": "\"{Redacted},1\"",
            "id": "Redacted",
            "lastModifiedDateTime": "2021-01-14T08:14:40Z",
            "name": "Ordner",
            "webUrl": "https://Redacted.sharepoint.com/sites/PowerAppsFunktionen/Freigegebene%20Dokumente/Ordner",
            "cTag": "\"c:{Redacted},0\"",
            "size": 367581,
            "createdBy": {
                "user": {
                    "email": "mmuster@Redacted.onmicrosoft.com",
                    "id": "Redacted",
                    "displayName": "Max Muster"
                }
            },
            "lastModifiedBy": {
                "user": {
                    "email": "mmuster@Redacted.onmicrosoft.com",
                    "id": "Redacted",
                    "displayName": "Max Muster"
                }
            },
            "parentReference": {
                "driveId": "Redacted",
                "driveType": "documentLibrary",
                "id": "Redacted",
                "path": "/drives/Redacted/root:"
            },
            "fileSystemInfo": {
                "createdDateTime": "2021-01-14T08:14:40Z",
                "lastModifiedDateTime": "2021-01-14T08:14:40Z"
            },
            "folder": {
                "childCount": 22
            }
        },
        {
            "@microsoft.graph.downloadUrl": "https://Redacted.sharepoint.com/sites/PowerAppsFunktionen/_layouts/15/download.aspx?Redacted&ApiVersion=2.0",
            "createdDateTime": "2020-11-05T22:17:07Z",
            "eTag": "\"{Redacted},9\"",
            "id": "Redacted",
            "lastModifiedDateTime": "2020-11-06T10:33:09Z",
            "name": "Mappe.xlsx",
            "webUrl": "https://Redacted.sharepoint.com/sites/PowerAppsFunktionen/_layouts/15/Doc.aspx?sourcedoc=%7BRedacted%7D&file=Mappe.xlsx&action=default&mobileredirect=true",
            "cTag": "\"c:{Redacted},15\"",
            "size": 23064,
            "createdBy": {
                "user": {
                    "email": "mmuster@Redacted.onmicrosoft.com",
                    "id": "Redacted",
                    "displayName": "Max Muster"
                }
            },
            "lastModifiedBy": {
                "application": {
                    "id": "Redacted",
                    "displayName": "App Service"
                },
                "user": {
                    "email": "mmuster@Redacted.onmicrosoft.com",
                    "id": "Redacted",
                    "displayName": "Max Muster"
                }
            },
            "parentReference": {
                "driveId": "Redacted",
                "driveType": "documentLibrary",
                "id": "Redacted",
                "path": "/drives/Redacted/root:"
            },
            "file": {
                "mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                "hashes": {
                    "quickXorHash": "Redacted"
                }
            },
            "fileSystemInfo": {
                "createdDateTime": "2020-11-05T22:17:07Z",
                "lastModifiedDateTime": "2020-11-06T10:33:09Z"
            }
        },
[...]
    ]
}

 

Has anyone had a similar experience? 

In the first Library i thought it might have to do with the number of items in the Library (about 25.000). But the others are all under 50 items.

2 Replies
Solution:
Noticed that it's probably a Problem with Permissions. I added some Permissions regarding the files.read.all and now it's working
I am seeing the same issue
Request:
https://graph.microsoft.com/v1.0/me/drives
Response
code:200
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#drives","value":[]}

where do you change the file.read.all permissions?