What's the userUri in UserRestClient.getUser(URI userUri)?

I am using Java REST API to develop a WEB front for my company.
The first thing is login:

JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, username, password);

Then to get the user information. There are TWO methods in UserRestClient:

UserRestClient userClient = jiraRestClient.getUserClient();
UserRestClient.getUser(String username);
UserRestClient.getUser(URI userUri);

The API doc says prefer the 2nd method over the first.
But that’s the userUri? How can I get it? All I have is username and password provided by the user.
I tried the first method [UserRestClient.getUser(String username)], but it does NOT work all the time. Sometime is OK, sometime it DOESN’T.

Please help! Thanks a lot!!!

Hi @xianyunjushi,

I have not tried that call, but can you try using the Rest API for GET user? example: http://localhost:2990/jira/rest/api/2/user?username=admin as the UserURI? I’ve checked the code base of the UserRestClient implementation and UserJsonParser, and it seems fit for the getUser(URI userUri).

Let me know if it worked.

Thanks!

Cheers,
Anne Calantog

1 Like

Or try the myself endpoint for the logged in user

@acalantog It works, thanks!

Hi @xianyunjushi,

Glad it did! Can you please mark this as solution for future developers?

Thanks!

Cheers,
Anne Calantog