Search On Hub and Associated HubSites using Graph API?

Ankur 1 Reputation point
2022-12-01T12:09:02.813+00:00

Hi

We have one Parent Hub and Associated 10 HubSites to the same. We want to search on all 11 Associated sites altogether.
Through Search API of SharePoint I am able to achieve it , but how to do it through GRAPH API.
Please help. This is bit urgent .

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,565 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,229 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,600 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,655 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 6,081 Reputation points
    2022-12-01T22:31:39.25+00:00

    Hi @Ankur

    You can use Search API to search content stored in OneDrive or SharePoint
    The Search API lets you scope the types of content to retrieve in OneDrive or SharePoint by specifying the entityTypes property on the searchRequest.
    Please refer to the below sample request. Replace contoso with your file name which you want to search.

    POST https://graph.microsoft.com/v1.0/search/query  
    Content-Type: application/json  
      
    {  
      "requests": [  
        {  
          "entityTypes": [  
            "driveItem"  
          ],  
          "query": {  
            "queryString": "contoso"  
          }  
        }  
      ]  
    }  
    

    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.


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.