title: Unknown error while calling Web API from Android
body: <p>i am trying to send a <code>JSONObject</code> as input parameter for a C# Web API with the following code</p>
  
  <pre><code>protected String doInBackground(JSONObject... companyInfo) {
  
      try {
          URL url;
          URLConnection urlConn;
  
          url = new URL(HOST_NAME + WEB_API_METHOD);
  
          urlConn = url.openConnection();
          urlConn.setDoInput(true);
          urlConn.setDoOutput(true);
          urlConn.setUseCaches(false);
          urlConn.setRequestProperty("Content-Type", "application/json");
          urlConn.setRequestProperty("Host", HOST_NAME);
          urlConn.connect();
  
          PrintWriter out = new PrintWriter(urlConn.getOutputStream());
          out.print(companyInfo[0]);
          out.close();
  
          BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
          StringBuilder stringBuilder = new StringBuilder();
          String line;
          while ((line = bufferedReader.readLine()) != null) {
              stringBuilder.append(line).append("\n");
          }
          bufferedReader.close();
  
          Log.i("companyInfo &gt; ", stringBuilder.toString());
      }
      catch (Exception ex)
      {
          Log.e("Exception", ex.getLocalizedMessage());
      }
      return null;
  }
  </code></pre>
  
  <p>When this is called, the method doesn't execute and when i try to catch the error, i don't get a meaningful message. it shows the URL name and thats it.</p>
  
  <p>I am unable to find the issue and any help would be appreciated.</p>
  
  <p>this is the error i got</p>
  
  <pre><code>java.io.FileNotFoundException: http://MY_FULL_URL
       at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:238)
       at com.fourtyninetons.NewCompanyActivity$saveCompanyProfile.doInBackground(NewCompanyActivity.java:103)
       at com.fourtyninetons.NewCompanyActivity$saveCompanyProfile.doInBackground(NewCompanyActivity.java:70)
       at android.os.AsyncTask$2.call(AsyncTask.java:295)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)
  </code></pre>
  
  <p>Lakshman. </p>