【问题标题】:MSGraph API filtering users returns BadRequestMSGraph API 过滤用户返回 BadRequest
【发布时间】:2022-08-17 14:58:13
【问题描述】:

我有以下代码:

 IConfidentialClientApplication app = ConfidentialClientApplicationBuilder
            .Create(clientId)
            .WithTenantId(tenantId)
            .WithClientSecret(clientSecret)
            .Build();
        ClientCredentialProvider authProvider = new ClientCredentialProvider(app);
        GraphServiceClient graphClient = new GraphServiceClient(authProvider);

        var users = await graphClient
            .Users
            .Request()
            .Filter(\"eq(mail, \'someEntity@mycompany.com\')\")
            .GetAsync();

上面抛出了以下异常:

代码:错误请求

消息:无效的过滤器子句

我究竟做错了什么?

  • 过滤器应该是 ---> .Filter(\"mail eq \'someEntity@mycompany.com\'\")
  • 谢谢,用户 1672994。这就是问题所在。
  • 我已经提出了答案。

标签: c# api msgraph


【解决方案1】:

根据 OData URI 约定(读取 here),过滤器 eq 应定义为 propertyName eq PropertyValue

所以将过滤器更新为

.Filter("mail eq 'someEntity@mycompany.com'")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多