Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

error 302 authentication jira rest api

jacob delddd
Contributor
July 19, 2018

I get the following error when running my code:

try {
log.info("try");
String sprintLocation = "http://user:pass@jira/rest/agile/1.0/board/"+j+"/sprint?startAt="+start;
URL url = new URL(sprintLocation);
URLConnection urlConnection = url.openConnection();
if (url.getUserInfo() != null) {
log.error("if statement");
String basicAuth = "Basic " + new String(Base64.getEncoder().encode(url.getUserInfo().getBytes()));
urlConnection.setRequestProperty("Authorization", basicAuth);
}

if ( urlConnection instanceof HttpURLConnection)
{
HttpURLConnection httpConnection = (HttpURLConnection) urlConnection;

log.warn(httpConnection.getResponseCode()+"");

}
StringBuilder temp = new StringBuilder();
log.info("stringbuilder");
String s = null;
InputStream inputStream = urlConnection.getInputStream();
log.info("inputstream");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
log.info("reader");
while ((s = reader.readLine()) != null) {
temp.append(s);
s = "";
}

error:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>302 Found</title></head><body><h1>Found</h1><p>The document has moved <a href="https://jira/rest/agile/1.0/board/1/sprint?startAt=0">here</a>.</p><hr><address>Apache Server at jira Port 80</address></body></html>

 

 

There is no exception when running the code. 

"The HTTP response status code 302 Found is a common way of performing URL redirection. The HTTP/1.0 specification (RFC 1945) initially defined this code, and gave it the description phrase "Moved Temporarily" rather than "Found"."  wikipedia

I can't seem to find my error or any relation with other 302-posts.

Thank you for your time

1 answer

0 votes
Aswin Achuthan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 18, 2021

Hi @jacob delddd , I am not sure if you are still looking for answer, but it might help others.

Try using https in the URL.

Suggest an answer

Log in or Sign up to answer