Hi,
In my Jira (server) plugin, I want to call call to a Jira REST API to execute a JQL statement: assignee = currentUser()
The URL for that query would be: http://localhost:2990/jira/rest/api/2/search?jql=assignee+%3D+currentUser()+
I tried it in my browser and it works.
So this is my code:
String searchURL = "http://localhost:2990/jira/rest/api/2/search?jql=assignee+%3D+currentUser%28%29+";
String searchURL = jiraBaseURL + SEARCH_URL + URLEncoder.encode(jql, "UTF-8");
URL url = new URL(searchURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
StringBuilder response = new StringBuilder();
String line;
while ((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
Some how I got a 400 (Bad request) error code. It’s not 401 (Authentication failed) error code. So I don’t know what is the the problem and how to fix it.
Is it a problem of calling Jira Rest API from Jira plugin which is running in same Jira instance?
Any help would be appreciated!