Can I Use the Microsoft Graph API to get the id of folder within a sharepoint document library? - microsoft-graph-api

Is it possible to use the microsoft graph api to get the id of a folder within a sharepoint document library? If so, how?
I can see in the documentation that I can get the path of a folder and/or file, and make queries based on this path. But what I would like is to get an id, so if the folder and/or file ever changes name, I can still query that specific folder and/or file. Is this possible?
Specifically, I am creating an internal dashboard for my employees. We have a Folder in a sharepoint document library called "Contacts". Within this "Contacts" folder we have n number of subfolders such as "John Doe," "Jane Doe," etc. If an employee is viewing the information for John Doe within our internal employee dashboard, I'd like to display the any child folders and/or files of John Doe.
Again, all I can find in the graph api documentation is how to query based on the relative path. I'd like to be able to use the API to get an id for any folder and/or file, as well as to return any child objects of any folder using the id (and not the relative path). How can I do this?

Yes it is possible. You should use the below query
https://graph.microsoft.com/v1.0/sites/{siteid}/drives/{document libraryid}/items/{folderid}/children.
If you want to get the folder id use this call
https://graph.microsoft.com/v1.0/sites/{siteid}/drives/{document libraryid}/root/children and get the id of the folder

Related

Retrieve a list of folders in SharePoint using Microsoft Graph

I’m using the graph api from a c# app to access SharePoint. I need to get a list of all folders and sub folders. I have tried getting the drive item and then iterating through the children looking for folders and then recursively working through the list but it’s too slow.
I have also tried this end point
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=fields&$filter=fields/ContentType eq 'Folder'
With this header
Prefer: HonorNonIndexedQueriesWarningMayFailRandomly
But it returned that the query would consume too many resources.
Is there a way to
A. Get the folders more efficiently or
B. Do a search to return folders or
C. Only list folders in the children endpoint
You can call this endpoint to get all files and folders in the specific library:
https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?$expand=driveItem

Is it possible to search for files within a directory in OneDrive using the Graph API

The official Graph API documentation states that it is possible to:
search within a folder hierarchy
However, the entire drive is searched when we perform a folder scoped search like the following:
https://graph.microsoft.com/v1.0/me/drive/root:/Folder:/search(q='file')?select=name,webUrl,driveId
This has been discussed here [2] but either this has changed in the last year or did not work in the first place.
Is this a bug or intended behaviour? Can we scope the search to a single directory?
Reference
[1] https://learn.microsoft.com/en-us/graph/api/driveitem-search?view=graph-rest-1.0&tabs=http
[2] How to search an item in specific folder in one drive?

find where file is in umbraco media section using id

I have a file being picked up externally which I've been told has been deleted by the author.
If I go into the Media section on the server I can find the folder with the id 343565 which has the "deleted" file in it.
There is a deep folder tree in our Media section when using the Umbraco backend, is there an easy way to search in the back end using the 343565 id to find it so I can check whether it has been deleted?
It would be useful to know how to do this in v7 too (if it is different) as I will be upgrading to v7 soon
Unfortunately, that id doesn't relate to the media id.
If you are using v6 or v7, you can use Examine to search the for folder id in the umbracoFile field.
Go to the Developer section
Select the Examine Management tab
Open the Internal Search under the Searchers section
Paste this into the search box: umbracoFile:/media*343565*
Select the Lucene Search radio button
Search
That should bring up the media node and from there you can get the id, path, etc

Sharepoint's "New Folder" doesn't ask for a required field

I am using Web Part Connections to filter documents in a documents library in SharePoint. To do this, there's a column that is required, which I've named "related contact." Here's my problem: When I go add a New Folder (instead of just a document) SharePoint only asks me for a title for the Folder. The "related contact" column (which is required for the documents) doesn't even appear. Since the info on that column is empty, web part connections doesn't see the folder at all. Is there any way to make the Folder ask for another field at the time of creation?
Thanks
-V
Did you try creating a new folder content type with those required fields and trying to use that (and perhaps turn off the standard folders)?
Perhaps this page will help you: SharePoint folders and metadata.
Folders are one-dimensional. They are virtual containers for your documents, but aren't objects in your library that contain actual metadata.
Instead of using folders, I would recommend adding a column to your library that would mimic the names of the folders. From there, you can sort/filter/group/query the contents of that library. If users are sticklers for the folder structure, you could create a View that groups the documents by that new column, which would give you the appearance of folders.

How to iterate through Folders and sub folders of a Sharepoint Document Library using web references

I am trying to access Folder names from Document Libraray using web services in C#.
I am to get the first level folder names using getlistitems.
Howvever i am not able to get sub folders and documents.
Can any body help me with this.
Use SiteData's EnumerateFolder method
http://msdn.microsoft.com/en-us/library/ms774758.aspx

Resources