title: HTTP 415 error in android
body: <p>I am fetching my code from <a href="http://ashapurasoftech.com/train/test.json" rel="nofollow">http://ashapurasoftech.com/train/test.json</a> and posting it to the WCF services in JSON format. However, I get a "415 Unsupported Media" error in my code.</p>
  
  <p>Can anyone tell me where to make the change?</p>
  
  <p>Below is my code:</p>
  
  <pre><code>public class S1 extends ListActivity implements OnClickListener {
      private static String url = "http://ashapurasoftech.com/train/test.json";
      private static final String TAG_a = "menu",TAG_Name = "Name",TAG_Cat = "Category";
  
      @Override
      protected void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.table1);
  
          lv =getListView();
          category_main = "";
  
          new Getitems().execute(category_main);
  
          sub = (Button) findViewById(R.id.submit);
          sub.setOnClickListener(this);
  
          b =(Button) findViewById(R.id.start);
          b.setOnClickListener(this);
  
          itemList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      }
  
      @Override
      public void onClick(View arg0) {
          switch(arg0.getId()){
              case R.id.start:
                  try {
                      Log.d("start","click");
                      onbuttonclick();
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
                  break;
              case R.id.submit:
                  Log.d("submi","click");
                  onsubmitclick();
                  break;
          }
      }
  
      private void onsubmitclick() {
          Log.d("submi inside","click");
          {
              new Thread()
              {
                  public void run(){
                      try {
                          EditText et = (EditText) findViewById(R.id.EditText05);
                          EditText et1 = (EditText) findViewById(R.id.EditText06);
                          TextView tx= (TextView) findViewById(R.id.name);
  
                          et.getText();
                          et1.getText();
                          tx.getText();
  
                          boolean isValid = true;
  
                          if (isValid) {
                              // POST request 
                              HttpPost request = new HttpPost("http://192.168.0.119:5204/Service1.svc/GetOrder");
                              request.setHeader("Accept", "application/json; charset=utf-8");
                              request.setHeader("Content-type", "application/json; charset=utf-8");
  
                              // Build JSON string
                              String json = "{'Order':[";
  
                              if(!et.equals(str)){
                                  String stra = "{'Table_id':"+Second.a+",'item_name':'"+tx.getText()+"','Item_quantity':'"+et.getText()+"','Item_additionaldetails':'"+et1.getText()+"'}";
                                  json = json+stra;
                              }
                              json = json + "]}";
  
                              Log.d("",""+json);
  
                              StringEntity entity = new StringEntity(json.toString());
  
                              request.setEntity(entity);
  
                              // Send request to WCF service
                              DefaultHttpClient httpClient = new DefaultHttpClient();
  
                              HttpResponse response = httpClient.execute(request);
  
                              Log.d("response:", "Saving : "
                                  + response.getStatusLine().getStatusCode());
                          } 
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              }.start();
          }
      }
  </code></pre>