I use a Sharepoint V1.0 API call
https://mydomain.sharepoint.com/mysite/_api/Web/GetFolderByServerRelativeUrl(parentfolder)?$select=Title,File/Name&$expand=Folders,Files
As part of a PHP function to build an array of files and folders.
Starting with the parent=""
The first level of folder and files are returned. For each folder returned, I pass the folder name into the parent
and build an array of parents and their children.
I end up with a nested array of files and folders which I can then json_encode()
and pass to a javascript tree plugin (jstree) for display on a website.
I am keen to use the GRAPH API to replace the SharePoint API as it is quicker and currently under on-going development (unlike the SharePoint API).
However, I am unable to find a way to use paths in the same way that GetFolderByServerRelativeUrl
does to allow me to traverse the folder hierarchy.
It seems that the GRAPH API relies on you making multiple calls to sites, drives/lists, drive/list items, etc to get id's.
I can get a site's id from a path using:
https://graph.microsoft.com/v1.0/sites/powernaturally.sharepoint.com:mysite
From there on I am finding it difficult to return files and folders at any level with the same call which I can put into a function and call recursivly.
Is there a way of traversing in a similar way as GetFolderByServerRelativeUrl
or should I take the performance hit of the SharePoint API and enjoy it while it lasts?