0

We are working on an implementation with our software and Sharepoint. For certain entities within our software we want to create a folder structure in Sharepoint and maintain this by updating the folders when needed.

Consider the following structure where we have some companies with a relation No and a searchcode. The id's are filled within the brackers.

Companies
-> 00011 - ITTER [7]
-> 00012 - WICO [8]

NI want to get the ItemId for the 00011 - ITTER [7] folder within the Companies folder but by only using the id that is between the brackets. So my first step would be to get the ItemId of the Companies folder and then go from there. But there doesn't seem to be a way to search for only a folder that contains something in the name?

I tried a couple of things:

https://graph.microsoft.com/v1.0/drives/<drive-id>/items/<company folder id>/search(q='{[7]}')

If I use the search query on the [7] I actually get 2 results back. One is the actual folder that I'm searching for, but the other is a Word document that is in a different folder! I'm not sure why this Word document shows up...

Another thing I tried was applying a filter:

https://graph.microsoft.com/v1.0/drives/<drive-id>/items/<company folder id>/children?$filter=startsWith(name,+'00011')

StartsWith does seem to work and returns the 00011 - ITTER [7] folder, but the EndsWith returns itemNotFound?

And if I try to combine the search and filter options to only return folders, this returns notSupported.

https://graph.microsoft.com/v1.0/drives/<drive-id>/items/<company folder id>/search(q='{[7]}')?filter=folder+ne+null
returns: 
    {
    "error": {
        "code": "notSupported",
        "message": "Only createdDateTime,remoteItem.shared.sharedBy.group.id,remoteItem.shared.sharedBy.user.id is supported for filtering",
        "innerError": {
            "date": "2023-04-19T13:06:44",
            "request-id": "d6a5e00c-d3a8-4456-a216-785393d92d5d",
            "client-request-id": "26cd1992-1831-5d13-ddd4-654b2094adc5"
        }
    }
}

I can't find anything about this on the documentation website: https://learn.microsoft.com/en-us/onedrive/developer/rest-api/concepts/filtering-results?view=odsp-graph-online

Anyone have an idea how to search for a specific folder within another folder?

0 Answers0