Praneeth
Praneeth

Reputation: 3

Microsoft Graph Java API - Filter Groups based on a boolean value

I am trying to filter the groups using java sdk based on the parameters like mailEnabled or securityEnabled.

I am trying out the following code to perform the same as suggested in the Graph Explorer interface. (https://developer.microsoft.com/en-us/graph/graph-explorer)

LinkedList requestOptions = new LinkedList(); requestOptions.add(new QueryOption("$filter", "mailEnabled+eq+true"));

IGroupCollectionPage groups = graphClient.groups() .buildRequest(requestOptions) .get();

But this throws an exceptio saying that "Invalid filter"

I can filter out the groups using the "startsWith" paramter as mentioned in "https://stackoverflow.com/questions/60417041/microsoft-graph-api-java-get-group-using-displayname"

Looks like there is some issue with + sign here.

Any suggestions ?

Upvotes: 0

Views: 1823

Answers (1)

Shiva Keshav Varma
Shiva Keshav Varma

Reputation: 3575

You can use the below code to get a filtered data for mailEnabled property.

List<Option> requestOptions = new ArrayList<Option>();      
requestOptions.add(new QueryOption("$filter", "mailEnabled eq true"));       
IGroupCollectionPage data = graphClient.groups()
                            .buildRequest(requestOptions)
                            .get();

Upvotes: 4

Related Questions