How to fetch the user roles in a project area in RRC programmatically?
We are working on RRC extension where I am trying to fetch the roles assigned to a user in the RRC Project area. Following is the code :
HttpGet query = new HttpGet("https://aab.acd.com/rm/process/project-areas/_Yt5AsiOrEeSYxYvpIWViQA/members/userName");
query.addHeader("Referer", "https://aab.acd.com/rm" + "/admin");
query.addHeader("DoorsRP-Request-Type", "private");
query.addHeader("Accept", "application/xml");
DefaultHttpClient hc = new DefaultHttpClient();
HttpResponse response = hc.execute(query);
I am getting a 401 Unauthorized Response. I am able to access the response xml from a normal browser. Am I missing out on anything?
One answer
Comments
Thanks Donald, and right, you should use the form based POST to get through the OAuth dance to get authenticated.
Achla, on the 401 response you should see 'a x-com-ibm-team-repository-webauth-msg : authrequired' header indicating that you are not authenticated.
For a code sample how to do that, you can look at the the OSLC Workshop pdf document, section 6.3; Jazz form-based authentication.
Also see wiki document Jazz Foundation Core Security - User Authentication
1 vote
Comments
Bas Bekker
JAZZ DEVELOPER Apr 08 '15, 11:14 a.m.What does the response content say, any details in the error message?
And do you have a user session with the RM server, i.e. are you authenticated?
And note that what you are trying to do is not part of the public REST API that RM and the Jazz platform provides.
Achla Sharma
Apr 09 '15, 2:52 a.m.The error message simply states Unauthorized with an error code 401. I tried authenticating using the login credentials. But the issue persists.
query.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials(login, password), "UTF-8",false));
Is there some other way to fetch the user roles in a project area?