Hello,
I am trying to use Search using Graph sdk 5.x.
I am able to fetch search results given that i pass region.
But i am not able to fetch region dynamically.
SiteCollection resource has datlocationcode null for single geo tenant.
https://learn.microsoft.com/en-us/graph/api/resources/sitecollection?view=graph-rest-1.0
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/multigeo-discovery
as mentioned in above link.
->I have also tried with graphClient.Organization , it doesnt have geo location.
->Also i have tried to give delegate permission for file.readall ,site.readall, search.config but the below code does't work without region and i am not able to fetch region dynamically.
->What i want is to fetch region dynamically or make work below code without using region.
Please help.
Please refer below code :
SearchRequest request = new SearchRequest();
string searchTerm = "test path:\"https://obscurepi.sharepoint.com/sites/SiteInfi2022\" AND candlelight";
SearchQuery query = new SearchQuery();
query.QueryString = searchTerm;
List<EntityType?> entityType = new List<EntityType?>();
entityType.Add(EntityType.DriveItem);
entityType.Add(EntityType.ListItem);
entityType.Add(EntityType.List);
Dictionary<string, object> keyValues = new Dictionary<string, object>();
keyValues.Add("region", "IND");
request.Query = query;
request.EntityTypes = entityType;
//request.AdditionalData = keyValues;
QueryPostRequestBody qprb = new QueryPostRequestBody();
qprb.AdditionalData = keyValues;
qprb.Requests = new List<SearchRequest> { request };
var result1 = GraphClient.Search.Query.PostAsync(qprb).Result;