Mark Ainsworth
Mark Ainsworth

Reputation: 857

MSGraph API filtering users returns BadRequest

I have the following code:

 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, '[email protected]')")
            .GetAsync();

The above throws the following exception:

Code: BadRequest

Message: Invalid filter clause

What am I doing wrong?

Upvotes: 0

Views: 151

Answers (1)

user1672994
user1672994

Reputation: 10849

As per OData URI convention (read here), the filter eq should be defined as propertyName eq PropertyValue.

So update the filter as

.Filter("mail eq '[email protected]'")

Upvotes: 1

Related Questions