Allow duplicate params when crafting the request
According to the API documentation (retrieve-users), to retrieve specific users you need to specify the params like this:
usernames=cjones&usernames=mwong
On my request I've done something like this:
request.addParam("usernames", "cjones");
request.addParam("usernames", "mwong");
As a response I'm getting information about only one user. I believe the problem is that the addParam method is adding fields to a TreeMap:
private SortedMap<String, Object> params = new TreeMap<String, Object>();
Since we can't have duplicate keys, we can't search for multiple users. I've also noticed that you can set a List as value on the addParam method. Something like this:
request.addParam("username", Arrays.asList("cjones", "mwong"));
But that's also not working, the raw response is:
{"stat":"OK","response":[]}
@pvazqu1 The intent is that passing the list is the correct approach for having multiple values, so we'll look into this and see why that isn't having the intended effect.
@pvazqu1 Hi! Thank you for report this issues. I do find a bug in our code and working on a fix now.
Just a side note, the example you give you used username instead usernames for
request.addParam("username", Arrays.asList("cjones", "mwong"));
I tried the usernames my self yet still not working.
Hey guys, do you have an estimate regarding when this will be fixed? For now I'm just using a work around but it would be awesome just to use this client. Thanks!
@pvazqu1 No estimate yet... it looks like the bug has been around a while so we're investigating it to see if/how it ever worked.
@pvazqu1 You uncovered quite a can of worms with our APIs that accept duplicate query string parameters. we're still working on a solution that won't break all existing clients.
@AaronAtDuo I understand. Sorry about that 😣
@pvazqu1 We've determined that having the duplicate query string parameters option was not going to be feasible, so our engineers are working on introducing a new way of specifying multiple users. When that's ready we'll update this SDK.
@pvazqu1 The new bulk endpoints that handle multiple parameters better have been released. The new way to retrieve multiple users is via the username_list parameter which replaces use of multiple username parameters. username_list should be a JSON-serialized array (i.e. a string). See the updated https://duo.com/docs/adminapi#retrieve-users for details.
Since this new parameter will just be a string, I think it should work with the existing client, but we haven't tested it yet; let us know if there's problems please.
I am hoping #77 will help with this. When #77 merged, you could use something like
request.addParam("username_list", new JSONArray(new ArrayList(Arrays.asList("username1", "username2", "username3"))));