List a SharePoint 365 folder or document library
Use the externalItems GraphQL query to retrieve a list of items in a SharePoint 365 folder or document library.
Entity types
This query supports the following entity types:
SharepointDriveSharepointFolder
Example request
The first sample code block illustrates a request to retrieve all the items (files and folders) under a specified document library.
{ externalItems(namespace:
"sharepoint",
filter: {
context:
{ id: "b!rf643eLuXEG"
type: "SharepointDrive" }
}, first: 100, after: "Ng==")
{ edges {
cursor node {
identity{ id type} ...
on ExternalContent { title} }
}
}
}
Example response
The second code block illustrates the corresponding response with the requested data for each item.
{
"data": {
"externalItems": {
"edges": [
{
"cursor": "Nw==",
"node": {
"identity": {
"id": "015ASHMI",
"type": "SharepointFolder"
},
"title": "Docs"
}
},
{
"cursor": "MTU=",
"node": {
"identity": {
"id": "015ASHMI",
"type": "SharepointFile"
},
"title": "landscape.jpg"
}
},
{
"cursor": "MTc=",
"node": {
"identity": {
"id": "015ASHMI",
"type": "SharepointFile"
},
"title": "sub1test.srt"
}
},
{
"cursor": "MjM=",
"node": {
"identity": {
"id": "015ASHMI",
"type": "SharepointFile"
},
"title": "text.txt"
}
},
{
"cursor": "MjQ=",
"node": {
"identity": {
"id": "015ASHMI",
"type": "SharepointFile"
},
"title": "text_de.txt"
}
},
{
"cursor": "MjU=",
"node": {
"identity": {
"id": "015ASHMI",
"type": "SharepointFile"
},
"title": "text_es.txt"
}
},
{
"cursor": "MjY=",
"node": {
"identity": {
"id": "015ASHM",
"type": "SharepointFile"
},
"title": "text_fr.txt"
}
}
]
}
}
}