I am getting sharepoint folders by using the graph api as follows
https://graph.microsoft.com/v1.0/me/joinedteams
This give me back Jon data with id, displayname etc.
I the call
https://graph.microsoft.com/v1.0/groups/{folder-id}/drive/items/root/children/
This gives back Json with files and folders.
Is there a graph api call that can give me back the id by using the path , instead of the Id ?
So if my folder is called TestFolder/TestA/TestB , cani access the contents and deails of this folder by using something like
https://graph.microsoft.com/v1.0/groups/TestFolder/TestA/TestB/drive/items/root/children/
I have tried using
https://graph.microsoft.com/v1.0/me/drive/root:/" + path + "/" \
but that is for onedrive not the sharepoint folder group folders.
Related
I have a folder in Outlook that has 20 sub folders , but if i use the following it only gets back the first 10.
https://graph.microsoft.com/v1.0/me/mailFolders/{folderId}/childFolders
I have also tried using
https://graph.microsoft.com/v1.0/me/mailFolders/{folderId}/?$top=250&$expand=childFolders
But still it only gets back the first 10.
Is there a way i can get back all the folders ?
Add $top to your first query
https://graph.microsoft.com/v1.0/me/mailFolders/{folderId}/childFolders?$top=25
The $top in your second query will be ignored because the query returns the specific mail folder not a collection.
I have OneDrive with a number of folders and sub folders .
So I have a root directory with folders as follows
.Main
.Folder1
.Folder1a
.Folder1b
.Folder1b1
.UserDetails
.TextFile.txt
So there are 3 parent folders Main, Folder1 and UserDetails and Folder1 has sub folders Folder1a and Folder1b and Folder1b has sub folder Folder1b1.
I have made a request to:
https://graph.microsoft.com/v1.0/me/drive/root/children
and try to traverse the result to retrieve the sub directories.
So in the response the list of the folders and the folders inside the folders .
Is there one call i can make that can give me back this data in a Json result set ?
From my understand of your question the desired behavior is for the response to return an object representation of your OneDrive contents.
MSGraph doesn't yet support this functionality, you would have to retrieve sub-folders per folder.
Based on this documentation, you can use the drive-id to make the following request to list the children:
GET https://graph.microsoft.com/v1.0/drives/{drive-id}/items/root/children
Or if you want to list the items in a sub-folder:
GET https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{item-id}/children
To list the children based on the Path:
GET https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{path-relative-to-root}:/children
The other way you can go about this, is to write a recursive function on the client side to fetch your oneDrive JSON object.
I have problem with graph API. I'm making search component in React. Of course there can be many files with same name so I need to display path to it also. Problem is with this endpoint:
https://graph.microsoft.com/v1.0/me/drive/root/search(q='book')
I noticed that when I'm searching for all drive elements I receive path to file. But when I'm using /me/drive endpoint to search for only my files there is no path in parentReference.
The only option to get path is making second request:
https://graph.microsoft.com/v1.0/me/drive/items/{parent_reference_id}
Is there any solution for this? I tried expanding parentReference but it's saying that it's not supported.
When ever you try to get the path of an item you can use the /Items/{itemId} endpoint that gives the ParentReference property with the path in it.
https://graph.microsoft.com/v1.0/me/drive/Items/{Itemid}
In your case as you are searching for book file, pull the id from there and use the above query to get the path.
I am getting the drive of my sharepoint using the following which returns the drive and its ID etc
GET https://graph.microsoft.com/v1.0/sites/mycompany.sharepoint.com:/sites/mysite:/drive
However the below call returns a "Bad Request, url specified is invalid". Has anyone got any ideas on what I am doing wrong?
GET https://graph.microsoft.com/v1.0/sites/mycompany.sharepoint.com:/sites/mysite:/drive/items
You can get the root folders like this
GET https://graph.microsoft.com/v1.0/sites/mycompany.sharepoint.com/sites/mysite/drive/root/children
Note that mysite/drive is the default drive.
You can use
GET https://graph.microsoft.com/v1.0/sites/mycompany.sharepoint.com/sites/mysite/drives/{driveId}/root/children
to identify the specific driveId.
There's no endpoint to get all items in a drive with every file from every subfolder at once.
Here is a similar question for your reference.
We are trying to retrieve all files under a folder recursively, but I can't find an API for that.
I've tried using the search API without a query, but this doesn't return anything.
https://graph.microsoft.com/v1.0/sites/root/drive/root/search(q='{}')
Is this possible in microsoft graph ?
It turns out the correct link is:
https://graph.microsoft.com/v1.0/sites/root/drive/root/search(q='')
Thanks #Marc LaFleur
2021 edit: this api unfortunately doesn't return all the files. So I ended up using the sharepoint delta api to sync sharepoint data locally, then I use a mysql query to find all files of a given folder (there is a child <-> parent relation in the files/folder metadata return from the API)
If you want to find all of the files recursively of a SharePoint Document Library (which is still a Drive), you can apply a filter on the Content type not being a Folder. for example:
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields,driveItem&$filter=fields/ContentType eq 'Document'
This will return all of the Documents (i.e.: anything not a folder) recursively. Since the driveItem is being expanded, you will have all of the DriveItem details needed.
I am able to list all items with this below :
{drive-root-id} is the /Drive/root "id" value return from :
https://graph.microsoft.com/v1.0/{site-id}/drive/root
Then :
https://graph.microsoft.com/v1.0/{site-id}/drive/items/{drive-root-id}/children