Issues reading from TBA API with Java

I’ve been trying to run this Java code to pull the data from the TBA API:

try {
			URL url = new URL("");
			HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); 
			httpcon.addRequestProperty("User-Agent", "Mozilla/5.0");
			InputStream is = httpcon.getInputStream();
			BufferedReader reader = new BufferedReader(new InputStreamReader(is));
			String line = null;
	        // read each line and write to System.out
	        while ((line = reader.readLine()) != null) {
		} catch(Exception e) {

And it prints this out in the console:

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<H1>301 Moved</H1>
The document has moved
<A HREF="">here</A>.

But when I follow the exact same link in Chrome, it outputs the JSON data fine. I feel like there is some simple thing I’m missing. Can anyone help me out?

These two URLs are different (no “www.” vs having “www.”). Chrome will automatically follow the 301, it seems like Java does not. Have you tried using the “www.” URL?

Thanks! I knew it was something silly like that but I couldn’t figure it out for the life of me. Guess URL autofill has made me lazy :smiley:

You are doing it already, but in case someone finds this in a search later, make sure you use the https URL as well.

This seems like an interesting API to suit your needs