It's all about the answers!

Ask a question

How to make use of JRS REST API via native http client??

praveen hanchinamani (275) | asked Dec 08 '17, 1:36 a.m.
edited Dec 11 '17, 2:12 a.m.

 Hi there,

I am trying to fetch information(Report Managers details) in the JRS application of IBM ALM(6.0.4-version) using JAZZ REST API -

I have been using native client HttpClient-4.X to achieve this. 
I have configured my http client as below -

1. configured not to validate certificates from server (So it allows all the requests and responses)
2. configured to use https protocol
3. configured with default user credentials

Please find the piece of code that i am trying to execute -

String requestUrl = "https://<Server>/rs/setup?method=reportManagers";
HttpClient httpClient = Utils.createCloseableHttpClient("userId", "userPassword");
HttpResponse documentResponse = httpClient.execute(httpGetRequest);

After execution the response throws - "401 Unauthorized" please find the response object content as below -

HttpResponseProxy{HTTP/1.1 401 Unauthorized [Date: Thu, 07 Dec 2017 07:32:08 GMT, X-Powered-By: Servlet/3.0, Cache-Control: private, no-store, no-cache, must-revalidate, Pragma: no-cache, X-FRAME-OPTIONS: SAMEORIGIN, errMsg: Unauthorized%20user, X-jazz-web-oauth-url: https://<Server>/jts/oauth-authorize?oauth_token=86e3157f893649c2afa97522f1fcd65a&oauth_callback=https%3A%2F%2F<Server>%2Frs%2Fsetup%3Fmethod%3DreportManagers%26request_token_secret%3DQwBnOcZPJMZOPqXcMOsldKeq8af2Q5MG1eQxNq4I, Vary: Accept-Encoding, Keep-Alive: timeout=10, max=100, Connection: Keep-Alive, Transfer-Encoding: chunked, Content-Type: application/json; charset=UTF-8, Content-Language: en-US] org.apache.http.client.entity.DecompressingEntity@750cd36d}

I could understand that the request internally calls OAuth authentication and retrieves the oauth_token and request_token_secret. 
But later fails to authenticate the user in resource server.

Hence i tried 
1. to hold credentials by using cache and cookies set to http client. Still the result is same.
2. Disabled the redirect, Still the result is same

Please let me know -
1. Am i trying to achieve the goal in right way?
2. Or there is different way to deal with JRS application's REST API.

Thank you in advance.

Be the first one to answer this question!

Register or to post your answer.