Share via

How do I retrieve multiple graph users selected using custom extensions?

Thorsten Ohrstrom Sandgren 0 Reputation points
2024-03-29T20:36:43.9166667+00:00

I want to retrieve a set of graph Users using the latest graph SDK. The result should have the custom attributes (extension_XYZ_attributeName) for the users.

This works (single user)
user = graphClient.users().byUserId("some_user_id").get(requestConfiguration -> {

rqueryParameters.select = new String[] {"id", "extension_appId_myuserid"}; });

This does not work (multiple returned users)

userCollectionResponse = graphClient.users().get(r -> {

r.queryParameters.select = new String[] {"id", "extension_appId_myuserid"};

});

The symptom is that the thread appears to be stuck during the execution of .get(...).

If the "extension_appId_myuserid" is removed, the call works (both for a single user and multiple returned users).

If the logic uses

graphClient.users().get()

then users are returned, albeit without any custom extension values.

Using Postman, this works:

https://graph.microsoft.com/v1.0/users?$select=id, extension_appId_myuserid

The returned set of users contain the custom attribute.

Using a previous version of the SDK works:

builder.buildRequest().select(selectedUserFields).get().getCurrentPage();

where selectedUserFields is "id, extension_appId_myuserid"

Please let me know what modifications I need to make to get the same results as in the previous version of the SDK.

Thanks,

Thorsten

Microsoft Security | Microsoft Graph

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.