Skip to main content
Question

Retrieve users via marker

  • May 22, 2025
  • 5 replies
  • 25 views

Forum|alt.badge.img

Hi, 

Need to know how we will get first 20 enterprise users and then get marker to read more users.

I found this method: BoxUser.getAllEnterpriseUsers(api, true, marker);

but didn't understand what need to set in fields in order to get the users.

With the above method, I am getting nullPointer exception and I have set marker as null .

5 replies

Forum|alt.badge.img

Hi Ritika,

The Box API documentation includes a request example in Java using the getAllEnterpriseUsers method.

The fields parameter is optional.

https://developer.box.com/reference/get-users/

Iterable<BoxUser.Info> users = BoxUser.getAllEnterpriseUsers(api, true, null); 

// Get marker
String marker = ((BoxResourceIterable<BoxUser.Info>) users).getNextMarker();

Thanks,

Marie


Forum|alt.badge.img

Hi Marie,

If I have only 2 users in that case why I am getting next marker.

Assumption : I should get next marker only when there are lot of users and the limit exceeds the no. of users at a time otherwise next marker should be null.

Need some clarification here.

 


Forum|alt.badge.img

Correct! You will only get a marker if there are more results to grab. 

Alex


Forum|alt.badge.img

Hi 395005653353

Can you please share a java sdk method by which I can set limit while getting enterprise users?

In api call I can see there is an option of limit, offset but not from java side.


Forum|alt.badge.img
Hi 1520957386202
 
Currently Box Java SDK does not allow user to set limit when getting enterprise users.
The API is designed this way that we are hiding marker/offset usage. You start by getting iterator over users:
Iterable<BoxUser.Info> users = BoxUser.getAllEnterpriseUsers(api, true, null);
now all the magic happens within SDK as you iterate over. So once your iterator  returns false it means that there are no more users.
users.forEach(u -> System.out.println(u.getName()));
should print two users if there are only those.
If you want to start from some position you can specify marker:
Iterable<BoxUser.Info> users = BoxUser.getAllEnterpriseUsers(api, true, 'position_to_start_from);
I've checked why you are getting next marker from SDK and it is API behaviour. If API returns any results it returns next_marker . This field will not be returned only when there are no users returned.