Graph API - Include image file information in search results

Ravi Natarajan 1 Reputation point
2021-07-08T08:58:54.507+00:00

I am using https://graph.microsoft.com/beta/drives/{{driveId}}/items/{{folderId}}/search(q='blah')?select=name,id,file. Its not returning images that have the specific value 'blah' set in one of the column.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,909 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Md Asif Muztaba 245 Reputation points Microsoft Vendor
    2023-12-28T02:09:41.4166667+00:00

    It seems like you’re experiencing an issue where the Microsoft Graph API is not returning image files when you specify a folder ID in your search query. This is a known issue.

    The problem appears to occur mostly with image files like PNG and JPG when you specify the parent folder’s ID in the search query. However, if you perform the search at the drive root level, those images can be found.

    One possible workaround suggested is to use the Search API, including ParentLink:/FolderName, along with Path to retrieve files and images from a parent folder within a document library. Here’s an example of how you might structure your request:

    POST https://graph.microsoft.com/v1.0/search/query
    {
      "requests": [
        {
          "entityTypes": ["driveItem"],
          "query": {
            "queryString": "searchstring AND Path:https://contoso.sharepoint.com/sites/Library/Shared Documents AND ParentLink:/FolderName"
          }
        }
      ]
    }
    

    This should return both files and images from the specified parent folder.

    Please note that it’s also possible that your requests are being throttled, especially if you’re seeing HTTP 429 responses. If that’s the case, you might consider using the Graph batch API to issue multiple queries at the same time.

    0 comments No comments