title: FileNotFoundException when loading API from URL. Java. Android
body: <p>Im trying to return a JSON string from this api:
  <a href="https://market.mashape.com/pareshchouhan/trivia" rel="nofollow">https://market.mashape.com/pareshchouhan/trivia</a></p>
  
  <p>however Java is throwing the error:</p>
  
  <pre><code>java.io.FileNotFoundException: https://pareshchouhan-trivia-v1.p.mashape.com/v1/getAllQuizQuestions?limit=10&amp;page=1
  </code></pre>
  
  <p>On the line</p>
  
  <pre><code>br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  </code></pre>
  
  <p>I have used similar code with other Rest APIs so i am a bit unsure why this is happenning.</p>
  
  <pre><code>    static String jsonStr;
      String data = "";
  
  
      @Override
      protected Void doInBackground(Void... params) {
          BufferedReader br = null;
  
  
          try {
  
              URL url;
              String urlStr = "https://pareshchouhan-trivia-v1.p.mashape.com/v1/getAllQuizQuestions?limit=10&amp;page=1";
              url = new URL(urlStr);
  
              URLConnection connection = url.openConnection();
              connection.setRequestProperty("X-Mashape-Key", "4OFryNEYTWmshe8GheSnmIVEj7gZp1kJf6cjsncjVhXj9WYACn");
              connection.setRequestProperty("Accept", "application/json");
              connection.setDoOutput(true);
  
              OutputStreamWriter outputStreamWr = new OutputStreamWriter(connection.getOutputStream());
              outputStreamWr.write(data);
              outputStreamWr.flush();
  
  
  
              br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
              StringBuilder sb = new StringBuilder();
              String line = null;
  
              while((line = br.readLine())!=null) {
                  sb.append(line);
                  sb.append(System.getProperty("line.separator"));
              }
  
              jsonStr = sb.toString();
  
  
          } catch (Exception e){
              e.printStackTrace();
          }
          return null;
  
      }
  </code></pre>
  
  <p>Any help would be greatly appreciated.
  Regards.</p>