首页 > 其他分享 >Status Code: BadRequestMicrosoft.Graph.ServiceException: Code: Request_UnsupportedQueryMessage: Unsu

Status Code: BadRequestMicrosoft.Graph.ServiceException: Code: Request_UnsupportedQueryMessage: Unsu

时间:2023-03-01 14:36:29浏览次数:55  
标签:Status count Code ServiceException Graph Request mail new

string filter = "endsWith(mail,'abc.com')";

Status Code: BadRequestMicrosoft.Graph.ServiceException:

Code: Request_UnsupportedQuery

Message: Unsupported Query.

 

Microsoft Graph Get All Users Exception Unsupported Query

回答1

You should send a header ConsistencyLevel=eventual and also $count query parameter to make it work.

To add $count query parameter you can use queryOptions.

List<QueryOption> queryOptions = new List<QueryOption>
{                                                  
    new QueryOption("$count", true) 
}; 

var users = await graphClient.Users
    .Request(queryOptions)
    .Filter("endswith(mail,'@mydomain.com')")
    .OrderBy("userPrincipalName")
    .GetAsync();

The API call what look something like this

https://graph.microsoft.com/v1.0/users?$count=true&$filter=endswith(mail, '@domain.live')&$orderBy=userPrincipalName

You can always test these calls in Graph Explorer.

 

https://github.com/microsoftgraph/microsoft-graph-docs/issues/10324#issuecomment-801222042你好

it works - you have to add a header

 var options = new List<Option>()

 options.Add(new QueryOption("$filter",
 "endsWith(mail,'ppedv.de') or endsWith(mail,'ppedv.at') "));

   options.Add(new HeaderOption("ConsistencyLevel", "eventual"));

    options.Add(new QueryOption("$count", "true"));

  var tmp = await graphClient.Users.Request(options).GetAsync();

 

标签:Status,count,Code,ServiceException,Graph,Request,mail,new
From: https://www.cnblogs.com/chucklu/p/17168046.html

相关文章