Why does trying to POST a node from Android result in "HTTP/1.1 415 Unsupported Media Type"? I used the following code to post some data to my site. I tested the site with Postman using the same data and it works properly, but when running the following code on Android Studio, response.getStatusLine() returns HTTP/1.1 415 Unsupported Media Type.

       HttpClient httpClient = new DefaultHttpClient();
       HttpPost httpPost = new HttpPost("http://www.example.com/entity/node");
       HttpResponse response = null;
       String responseBody = "";


       try{
           JSONObject json = new JSONObject();
           JSONObject c0 = new JSONObject();
           JSONObject c00 = new JSONObject();
           JSONObject c1 = new JSONObject();
           JSONObject c2 = new JSONObject();


           json.put("_links",c0);
           json.put("title",c1);
           json.put("type",c2);

           c0.put("type",c00);
           c00.put("href","http://www.example.com/rest/type/node/article");
           c1.put("value", "test string");
           c2.put("target_id", "article");


           String base64EncodedCredentials = "Basic " + Base64.encodeToString(
                   ("user"+ ":" + "pass").getBytes(),
                   Base64.NO_WRAP);


           StringEntity se = new StringEntity(json.toString());



           se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));

           httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json");
           httpPost.setHeader("Authorization", base64EncodedCredentials);

           httpPost.setEntity(se);

           // Execute HTTP Post Request
           response = httpClient.execute(httpPost);

           String jsonResponse = EntityUtils.toString(response.getEntity());
           JSONObject jsonObj = new JSONObject(jsonResponse);

           if (response.getStatusLine().getStatusCode() == 200) {
               Log.v("response ok", "ok response :/");
           } else {
               Log.v("response not ok", "Something went wrong :/");
           }
       catch (Exception e){
           Log.v("Error posting:",e.getMessage());
       }


I tested each of these lines separately and together, but none of them work.

    se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));

           httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json");


Why does it return HTTP/1.1 415 Unsupported Media Type?
I have faced same problem with same situation as you described above. 
After spending 2-3 hours I have got data through:

$formdata = file_get_contents('php://input');


It's worked for me.