title: Android HttpPost request exception
body: <p>Just as a demonstration the code will work, I am attempting to fetch some JSON data within my oncreate function. I know it should run on a different thread but I want to be sure the code successfully fetches my JSON before moving it into it's own thread.</p>
  
  <p>The code is below:</p>
  
  <pre><code>        @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main_activity);
  
          /***************************************************/
          final String TAG = "PostFetcher";
          final String SERVER_URL = "http://kylewbanks.com/rest/posts";
  //        final String TAG = "PostsActivity";
  //        List&lt;Post&gt; posts;
  
          try {
              //Create an HTTP client
              HttpClient client = new DefaultHttpClient();
              HttpPost post = new HttpPost(SERVER_URL);
  
              //Perform the request and check the status code
              HttpResponse response = client.execute(post);
              StatusLine statusLine = response.getStatusLine();
  
              if(statusLine.getStatusCode() == 200) {
                  HttpEntity entity = response.getEntity();
                  InputStream content = entity.getContent();
  
                  try {
                      //Read the server response and attempt to parse it as JSON
                      Reader reader = new InputStreamReader(content);
  
                      GsonBuilder gsonBuilder = new GsonBuilder();
                      gsonBuilder.setDateFormat("M/d/yy hh:mm a");
                      Gson gson = gsonBuilder.create();
                      List&lt;JsonObject&gt; posts = new ArrayList&lt;JsonObject&gt;();
  
                      Log.e(TAG, "Checking: " + posts);
  
  //                    posts = Arrays.asList(gson.fromJson(reader, JsonObject[].class));
                      content.close();
  
                  } catch (Exception ex) {
                      Log.e(TAG, "Failed to parse JSON due to: " + ex);
                  }
              } else {
                  Log.e(TAG, "Server responded with status code: " + statusLine.getStatusCode());
              }
          } catch(Exception ex) {
              Log.e(TAG, "Failed to send HTTP POST request due to: " + ex);
          }
  }
  </code></pre>
  
  <p>When I run the code, I get the second to last exception message:</p>
  
  <pre><code>Server responded with status code: 500
  </code></pre>
  
  <p>Can anyone please tell me what I'm doing wrong?</p>