Graph API search with empty array result which is not expected?

Henry Jia 21 Reputation points
2022-12-30T02:16:03.263+00:00

We found when search file in SharePoint drive, if the site name with single quote (') won't get the expected file list but empty array.
The API is something like
https://graph.microsoft.com/v1.0/sites/yxkns.sharepoint.com,8f355808-28a8-4de0-b6f1-5c16825ae7e0,0d16a123-58cf-4884-9d87-448c2265f588/drive/items/root/search(q='xlsx')

Normal site will get expected result as following:
274914-filelist.png
and the corresponding information about the site
274973-checksite2.png

But for site which name contains single quote will get empty array just like:
274986-emptyresult.png
and the site information is
275002-checksite1.png

Would any of you check what's wrong or is any solution to make the search works.

Thanks in advance,

Henry

Microsoft 365 and Office SharePoint Development
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,251 Reputation points
    2022-12-30T07:08:56.333+00:00

    Hi @Henry Jia ,

    According to my research and testing, as a workaround, you can search in SharePoint using the following Graph API:

    POST https://graph.microsoft.com/v1.0/search/query  
    
    {  
        "requests": [  
            {  
                "entityTypes": [  
                    "listItem"  
                ],  
                "query": {  
                    "queryString": "xlsx path:\"https://xxxxx.sharepoint.com/sites/zella'site/Shared%20Documents\""  
                }  
            }  
        ]  
    }  
    

    My test result:
    274960-01.png

    More information for reference: https://learn.microsoft.com/en-us/graph/search-concept-files#example-5-use-filters-in-search-queries

    Hope it can help you. Thanks for your understanding.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



  2. HarmeetSingh7172 4,826 Reputation points
    2022-12-30T07:18:26.5+00:00

    Hello @Henry Jia

    Thanks for reaching out.

    I'm able to reproduce the issue using my test tenant. I would recommend you to raise a support case with Microsoft Graph, a Support Engineer will be able to assist you better. You can raise support ticket from
    http://aad.portal.azure.com/ or https://admin.microsoft.com/#/support/requests.

    However, as an alternative, you can use Microsoft Search API to search across multiple SharePoint Sites.
    Please find this similar post answered by me: https://learn.microsoft.com/en-us/answers/questions/909314/index.html

    Hope this helps.

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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.