101 status code on simple query

Avatar image for yannicxyz
yannicxyz

2

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Hello everyone.

I'm learning how to use the API right now and I ran into a problem. My code looks like this so far:

String gbURL = "http://www.giantbomb.com/api/search/?api_key=THIS-IS-WHERE-MY-API-KEY-IS&format=json&query='sonic'&resources=game";
HttpURLConnection urlConnection = null; URL url = new URL(gbURL); 
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();

BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null)
{
sb.append(line + "\n");
}
br.close();
String jsonString = sb.toString();
System.out.println("JSON: " + jsonString);






However, as a result, I always get the 101 status code. As far as I know this means "object not found". But there should definitely be results for "sonic", right?



Avatar image for conmulligan
conmulligan

2292

Forum Posts

11722

Wiki Points

0

Followers

Reviews: 0

User Lists: 11

Have you tried fetching the HTTPS endpoint? GB redirects all http:// requests to the equivalent https:// URL and HttpURLConnection may not be following those automatically. Also, you can probably leave out the quotes around 'sonic'.