Can't use Microsoft Search Api with application permissions

Smart IT Admin (EXT) 0 Reputation points
2023-03-13T19:34:22.7133333+00:00

I need to search Sharepoint content by specific text. i use Microsoft Search Api with application permissions
User's image

Performing a search with application permission is limited to one geographic region. I must specify region in search request to run a search. But have a problem with getting a region value. 

On this link we have a documentation with this https://learn.microsoft.com/en-us/graph/search-concept-searchall
Tried the request to get the region value but we can't get the "dataLocationCode" with the code of region.

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

1 answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points
    2023-03-13T20:30:10.64+00:00

    Hello Smart IT Admin (EXT)

    Thanks for reaching out!

    As per the official documentation, performing a search with application permission is limited to one geographic region. You need to specify a value for the region property in your search request when you use application permissions to run a search. To get the region value for a tenant, use the dataLocationCode property of the siteCollection resource. For more information and examples, see Get the region value.

    You can get the geo location information for a tenant by using Microsoft Graph. Below sample code uses the dataLocationCode attribute on the siteCollection object.

    GET https://graph.microsoft.com/beta/sites?filter=siteCollection/root%20ne%20null&select=webUrl,siteCollection

    However, by default, application permissions enable search on shared content and disable search on private content. To enable private content search, please refer Include-all-private-content

    Also, refer Discover whether your tenant is Multi-Geo

    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.