Microsoft graph API: /me/drive/root/search - no path to found file - microsoft-graph-api

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.

Related

How do you get available Iteration Paths from Azure DevOps Services REST API?

I cannot find how to retrieve the iterations Paths from the API. I was able to get the parent paths but not child paths.
Tried with below Get command. It is giving just parent iterations but not a child.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/classificationnodes?$depth={$depth}&api-version=5.0
I'm using powershell.
If you're trying to get child paths, try using:
GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/iterations?api-version=5.1
{team} is not required. You can check this document for more details.
More details:
1.Assuming I have such Iterations:
2.Use this Get request in postman to test:
https://dev.azure.com/MyOrgName/MyProjectName/_apis/work/teamsettings/iterations?api-version=5.1
3.The response will list all child Iterations like this:
A bit late, but the issue is likely that the url contains a $ which needs to be escaped with a ` in powersell so it doesn't get interpreted as the start of a variable name.

Mircrosoft Graph API: List all DriveItems in a drive : badRequest

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.

List all files recursively in microsoft graph

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

Sensenet : Search documents by its content

I can see the document list can be searched by matching a value of document properties.
But I need to search document list which has a specific word in their content.
How can I achieve this by oData.svc query?
Is it possible using Lucene Index concept?
If yes then how?
Updated
I am working with Sense/Net 6.3.0.6337 Community Version.
I have tried to achieve it by following query
https://example.com/OData.svc/workspaces/Document/abcd_gmail_com/Document_Library/?metadata=no&$select=*&query=Taruna
It is working for .docx and .txt files only but doesn't work for .xml and .pdf file.
Is it sensenet version issue?
Thanks
You can add a query string argument called "query" to each and every GET request, e.g. http://www.example.com/OData.svc/?$select=Name,Index,Icon&query=about
returns content that contain "about" from the whole requested site
You can find more examples here in the Custom Query Options section

Google Drive queryForFilesList not returning any results

I'm currently having issues with the iOS Google Drive SDK. I'm using GTLQueryDrive queryForFilesList to search for a file in my Google Drive. All the files I want have a path in the format directory-name/file-name. Since the SDK/API doesn't allow searching for files using a full path, I'm using the following query to ultimately get it's downloadUrl. I'm using a query in the following format:
((title = 'directory-name') AND ('root' in parents) AND (mimeType = 'application/vnd.google-apps.folder')) OR
((title = 'file-name') AND (not 'root' in parents) AND (mimeType != 'application/vnd.google-apps.folder'))
The first line is meant to find all directories in the root directory whose name matches mine, and the second line should match all files with the same name. This should return the directory i'm looking for, the file i'm looking for, and maybe some other stuff (e.g. files with the same name in other directories). I have some code to figure out which file is the correct one.
The problem I'm having is that sometimes I get no results from the query. This generally happens after I rename the file, and rename it back, or other things like that. The weird part is that if I run either of the two lines of the query independently, it returns correctly, but together they don't.
Any help would be greatly appreciated, and I would gladly provide more information if required.
And yes, I'm using the kGTLAuthScopeDrive scope.
The ideal solution would be if I could just search using a full path, so if there's a way to do this, then I'm not aware.
Unfortunately, I was unable to get this to work. And also unfortunately, Google does not provide an API to query for a full path. So I resorted to iterating over the path to get the directory IDs, and then when I get to the file, get its ID and download it. Although slightly more complex, my solution was based on this question and chosen answer: What's the right way to find files by "full path" in Google Drive API v2

Resources