title: Google custom search api in android application
body: <p>i've been trying to use the Google custom search api for a school work and been running in to some issues when trying to get the json format of the result, i've configured everything on Google developer console and the Google custom search engine control panel, at least so i think. Here is a my code snippet</p>
  
  <pre><code>String qstring = "key="+key + "&amp;cx="+ cx +"&amp;q="+searchtext+"&amp;alt=json"+"&amp;start="+"0";
      String query = null;
      try {
          query = URLEncoder.encode(qstring, "UTF-8")
          .replaceAll("\\%28", "(")
          .replaceAll("\\%29", ")") 
          .replaceAll("\\+", "%20") 
          .replaceAll("\\%27", "'") 
          .replaceAll("\\%21", "!") 
          .replaceAll("\\%7E", "~");
      } catch (UnsupportedEncodingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      URL url = null;
      try {
          url = new URL("https://www.googleapis.com/customsearch/v1?" + query);
      } catch (MalformedURLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      HttpURLConnection conn2 = null;
      try {
          conn2 = (HttpURLConnection) url.openConnection();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      try {
          conn2.setRequestMethod("GET");
      } catch (ProtocolException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      conn2.setRequestProperty("Accept", "application/json");
      try {
          BufferedReader br = new BufferedReader(new InputStreamReader(
          (conn2.getInputStream())));
          String line;
          while ((line = br.readLine()) != null) {
              content.append(line + "\n");
          }
          br.close();
  
      return content.toString();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>and the error being displayed in the logcat</p>
  
  <pre><code>04-22 07:26:36.253: W/System.err(4229): java.io.FileNotFoundException: https://www.googleapis.com/customsearch/v1?key%3DAIzaSyBgvvgYg3mYS66fMM9j0qpaG6wlvUc1KLk%26cx%3D008838294879486691568%3Axy_pvqrl6fa%26q%3Djava.pdf%26alt%3Djson%26start%3D0
  04-22 07:26:36.289: W/System.err(4229):     at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
  04-22 07:26:36.321: W/System.err(4229):     at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271)
  </code></pre>
  
  <p>I would appreciate a point in the right direction incase i'm doing something wrong. please help!</p>