Search files with given file name substring in OneDrive

Dhruvin Moradiya 30 Reputation points

I want to search for files in a specific folder based on the given file name (it can be a substring of the file name).
/me/drive/search(q='Contoso Project') Endpoint searches this q parameter across several fields. I want that it to search for file names only.

If five files have 'test' as a substring in their name, then /me/drive/search(q='test') API should return five files only. Right now, it's returning mode then five files (comparing substring 'test' with multiple fields).

Any Idea how to limit search queries to file names only?

Also, /me/drive/search(q='Contoso Project') endpoint doesn't return all types of files. I want all types (mimeTypes) files in search results.

Microsoft Graph Files API
Microsoft Graph Files API
A Microsoft API to create an app that connects with files across OneDrive, OneDrive for Business, and SharePoint document libraries.
321 questions
Microsoft Graph Search API
Microsoft Graph Search API
A Microsoft API that searches for information in email messages, returns messages ranked by relevance, and renders a dedicated search experience.
164 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sayantan Ganguly-MSFT 530 Reputation points Microsoft Vendor

    Hello Dhruvin Moradiya,

    Thanks for reaching out!

    To get files in a specific folder based on the given file name please refer to the documentation. Including ParentLink:/FolderName, along with Path should be able to retrieve files and images as well from a parent folder.

    "requests": [  
            "entityTypes": [  
            "query": {  
                "queryString": "searchstring AND Path: Documents AND ParentLink:/FolderName"  

    Please refer to the similar post:

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".