I am currently working on a WinForms application that interacts with our SPO environment, using the Graph SDK. The application is written in .NET 4.7.2, and uses the “Microsoft.Graph” (SDK) 4.19.0.
Simplified code:
Dim srObject As New SearchRequestObject()
srObject.Query = New SearchQuery()
srObject.EntityTypes = New List(Of EntityType) From {EntityType.DriveItem}
srObject.Query.QueryString = String.Format("{0} AND isDocument=True", searchValue)
Dim lstSearchQueryOptions As New List(Of SearchRequestObject)()
lstSearchQueryOptions.Add(srObject)
Dim responsePage = Await _graphClient.Search.Query(lstSearchQueryOptions).Request().PostAsync()
If (Not responsePage Is Nothing) AndAlso (Not responsePage.CurrentPage Is Nothing) Then
...
End If
In order to perform the needed tasks, our Azure AD application has been given the needed “Application permissions”. However, I keep getting the following error when executing the Search Query:
Status Code: BadRequest
Microsoft.Graph.Service Exception: Code: BadRequest
Message: SearchRequest Invalid (Region is required when request with application permission.)
Details: Detail0: Code: Microsoft.SubstrateSearch.Api.ErrorReporting.ResourceBasedExceptions.BadRequestException
Message: Region is required when request with application permission.
AdditionalData: httpCode : 400
I can’t seem to find any property to add the “Region” information on the request.
Is there any way to add this property? Or otherwise, any way to resolve this issue?