title: Set http header using httpurlconnection
body: <p>Hi I have a problem setting the header of a http request, this is the code I'm using </p>
  
  <pre><code>    public static JSONObject getJSONObjectFromURL(String urlString, String version, String menuTop, String menuBottom) throws IOException, JSONException {
  
      HttpURLConnection urlConnection = null;
  
      URL url = new URL(urlString);
  
      urlConnection = (HttpURLConnection) url.openConnection();
  
      urlConnection.setRequestMethod("GET");
  
      urlConnection.setRequestProperty("X-Mobile-Version", MessageFormat.format("android/{0}", version));
      urlConnection.setRequestProperty("X-Menu-Hash", menuTop);
      urlConnection.setRequestProperty("X-MenuBottom-Hash", menuBottom);
  
      urlConnection.setReadTimeout(10000 /* milliseconds */ );
      urlConnection.setConnectTimeout(15000 /* milliseconds */ );
      urlConnection.setDoOutput(true);
      urlConnection.connect();
  
      //Log.d("-------------------....",urlConnection.getRequestProperty("X-Mobile-Version"));
  
      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();
      Log.d("..........JSon", jsonString);
  
      return new JSONObject(jsonString);
  }
  </code></pre>
  
  <p>but I always get the following error</p>
  
  <pre><code>W/System.err: java.io.FileNotFoundException: endpoint/
  W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251)
                at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
                at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(Unknown Source:0)
                at java.net.URL.openStream(URL.java:1058)
                at com.example.bordi.hotel.DataManager.getJSONObjectFromURL(DataManager.java:109)
                at com.example.bordi.hotel.DataManager$1.run(DataManager.java:132)
                at java.lang.Thread.run(Thread.java:764)
  </code></pre>
  
  <p>How can I solve? Thanks in advance!</p>