I am having trouble trying to get HttpURLConnection to follow redirects. What I am trying to accomplish is getting the xml file from a rest api. Here's the code I wrote for the connection.
URL url = new URL("***some url*****");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("GET");
conn.setDoInput(true);
conn.setFollowRedirects(true);
conn.addRequestProperty("X-IntegrationServer-Username", "");
conn.addRequestProperty("X-IntegrationServer-Password", "");
conn.setRequestProperty("ContentType", "application/xml");
conn.setRequestProperty("Host", "");
conn.connect();
out.print("<br>Response code = " + conn.getResponseCode());
out.print("<br>Response message = " + conn.getResponseMessage() + "<br><br>");
On my page I am getting a 302 response code still
Response code = 302
Response message = Found
Where can I look to see why this redirect isn't happening. I thought setting .setfollowredirects took any 3xx response and continued. Am I missing something?
If it means anything I did get this URL connection to work with php and a webdebugger fiddler and was able to get the data.
UPDATE
I think the issue might actually revolve around going from http and being redirected to a https link. I saw that in another topic but didn't see that mine was similiar to now.