405 error for while hitting /groups endpoint for the user

I am trying to hit the below endpoint and getting 405 error… got the userid from /userinfo

But this URL works fine in postman and giving me the list of groups assigned to the user. but in java code its giving 405.

URL url1 = new URL(oktaURL);
httpsClient = (HttpsURLConnection) url1.openConnection();
httpsClient.setRequestProperty("Authorization", "SSWS " + apiToken);

Please help…

405 errors indicate you’re using the wrong HTTP verb. GET is correct…any chance it was another verb at some point and you need to re-compile?

1 Like

I am not really sure about that. I did restart my system and also eclipse… it didnt not help.

Have you tried using our Java Management SDK? It has a built in listGroups method you can use to make this call for you.

1 Like

Thanks Andrea, this worked for me and I am able to get the groups with java SDK. Thank you.

One follow up question on this.
How to get the users list from the groups?

I tried listUsers method… this lists all the users from all the groups. I am looking for some way to get only users on a particular group in the SDK.

Please advice.

There’s a listUsers method you can use on a Group that should work

1 Like

This worked great. Thanks Andrea.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.