Hi everyone,
I am trying to make a GET call to Jira URL in Java using HttpURLConnection - getting 500 server error
If I make same call using postman - it works.
String url = "https://jira.mydomain.com/rest/raven/2.0/api/testrun/?testExecIssueKey=T22&testIssueKey=T2;
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
String basicAuth = "Basic :" + new String(Base64.getEncoder().encode(credentials.getBytes()));
con.setRequestProperty ("Authorization", basicAuth);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
System.out.println(responseCode);
Can someone please help and see whats going wrong?
Hi @abhay99 ,
welcome to the Atlassian community!
What seems suspicious in your code to me:
1)
String url = "https://jira.mydomain.com/rest/raven/2.0/api/testrun/?testExecIssueKey=T22&testIssueKey=T2;
Possible missing double-quote in the end of the line?
String url = "https://jira.mydomain.com/rest/raven/2.0/api/testrun/?testExecIssueKey=T22&testIssueKey=T2";
2)
String basicAuth = "Basic :" + new String(Base64.getEncoder().encode(credentials.getBytes()));
There should't be : after word Basic
String basicAuth = "Basic " + new String(Base64.getEncoder().encode(credentials.getBytes()));
Thanks for your response. 1st pointer was a typo and 2nd pointer did the trick, it works now. Very weird that for this reason I was getting 500 error, should have got 401 instead. Anyway, it works now. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.