我们如何使用Basic Auth使用HttpGet进行Rest调用以使用JSON并在Spring MVC中对其进行迭代?

时间:2019-03-12 12:03:00

标签: java rest

I have a Rest API - http://10.199.4.46:8081/jira/rest/api/2/issue/CQ-12836?expand=changelog  which returns Json in response.

How do we make Rest call with HttpGet using Basic auth to consume JSON response & iterate it in spring mvc in Java?

I have written the below code but not sure that it is correct or not.

//rest call to fetch the issue
            HttpClient client = new DefaultHttpClient();
            HttpGet request = new HttpGet("http://10.199.4.46:8081/jira/rest/api/2/issue/CQ-12836?expand=changelog");
            HttpResponse response = null;
            request.addHeader(BasicScheme.authenticate(
                     new UsernamePasswordCredentials("acUser", "acPsswd"),
                     "UTF-8", false));

我不确定如何调用rest服务并获取json响应。

请在这里帮助我。

0 个答案:

没有答案