When I call below url from graph exlorer:
https://graph.microsoft.com/v1.0/me/drive/root:/folder2/children
I get below error:
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
But when I call same url without the /children :
https://graph.microsoft.com/v1.0/me/drive/root:/folder2
Then it works and returns the information for folder2. Folder2 is under root directly and contains files and other folders.
Is this an issue in the graph api or is it something I am doing wrong? This is in OneDrive for Business.
The :{path}:
tells the API that you want to address an item by its path rather than it's ID. In your URI, you're missing the closing :
which leaves the API attempting to find the path /folder2/children
rather than the path /folder2
and the API action /children
.
Breaking this down to its components:
https://graph.microsoft.com
/v1.0
/me/drive/root
:/folder2:
/children
Put together, your URI should look like this:
https://graph.microsoft.com/v1.0/me/drive/root:/folder2:/children
Also note that if folder2
contained a sub-folder named folder3
, you can address that by path as well:
https://graph.microsoft.com/v1.0/me/drive/root:/folder2/folder3:/children