101 status code on simple query

Avatar image for yannicxyz
#1 Posted by yannicxyz (2 posts) -

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();

BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null)
sb.append(line + "\n");
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
#2 Posted by conmulligan (1946 posts) -

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'.