Welcome to the new Box Support website. Check out all the details here on what’s changed.

Retrieve users via marker

Answered
New post

Comments

5 comments

  • Official comment
    Alex Novotny

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

    Alex

    Comment actions Permalink
  • Marie Rogers

    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

    1
    Comment actions Permalink
  • Ritika raina

    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.

     

    0
    Comment actions Permalink
  • Ritika raina

    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.

    0
    Comment actions Permalink
  • Kamil Berdychowski
     
    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.
    0
    Comment actions Permalink

Please sign in to leave a comment.