Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow duplicate params when crafting the request #68

Open
pvazqu1 opened this issue May 31, 2023 · 9 comments
Open

Allow duplicate params when crafting the request #68

pvazqu1 opened this issue May 31, 2023 · 9 comments

Comments

@pvazqu1
Copy link

pvazqu1 commented May 31, 2023

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":[]}
@AaronAtDuo
Copy link
Contributor

@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.

@yizshi
Copy link
Contributor

yizshi commented Jun 8, 2023

@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.

@pvazqu1
Copy link
Author

pvazqu1 commented Jun 13, 2023

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!

@AaronAtDuo
Copy link
Contributor

@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.

@AaronAtDuo
Copy link
Contributor

@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.

@pvazqu1
Copy link
Author

pvazqu1 commented Aug 16, 2023

@AaronAtDuo I understand. Sorry about that 😣

@AaronAtDuo
Copy link
Contributor

@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.

@AaronAtDuo
Copy link
Contributor

AaronAtDuo commented Oct 6, 2023

@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.

@yizshi
Copy link
Contributor

yizshi commented Oct 10, 2023

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"))));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants