Retrieve users via marker
AnsweredHi,
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 .
-
Official comment
Correct! You will only get a marker if there are more results to grab.
Alex
Comment actions -
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
-
Hi Alex Novotny
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.
-
Hi Ritika rainaCurrently 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 returnsnext_marker
. This field will not be returned only when there are no users returned.
Please sign in to leave a comment.
Comments
5 comments