Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Android REST API HttpPost sends empty data on Post body
    primarykey
    data
    text
    <p>Im trying to send some data via HttpPost but it comes out empty. below if my method and HttpGET part is working good. but when i try to add some data to Post body and send, I get no error and Logcat (+ REST web service on the other side) show Post data was empty.</p> <pre><code> public void sendPhoto(View v) { final String kookojaUrlGet = "http://localhost/getData"; final String kookojaUrlPost = "http://localhost/postData"; new Thread(new Runnable() { @Override public void run() { HttpClient httpClient = new DefaultHttpClient(); try { HttpResponse getResponse = httpClient.execute(new HttpGet(kookojaUrlGet)); String returnedStuff = EntityUtils.toString(getResponse.getEntity()); Log.d("debug","http get returned " + returnedStuff); JSONObject jsonGet = new JSONObject(returnedStuff); int xxxTime = jsonGet.getInt("timestamp"); String xxxNone = jsonGet.getString("nonce"); String xxxApp = jsonGet.getString("appName"); String xxxCID = jsonGet.getString("csrfToken"); Log.d("debug","json was " + xxxTime + " " + xxxNone + " " + xxxApp + " " + xxxCID); JSONObject c = new JSONObject(); c.put("_username","xxx@gmail.com"); c.put("_password","123"); c.put("_timestamp", xxxTime); c.put("_nonce", xxxNone); c.put("_appName", xxxApp); c.put("CID", xxxCID); c.put("body", photoPost); c.put("long", photoLong); c.put("lat", photoLat); StringEntity sendStuff = new StringEntity(c.toString()); HttpPost xxxPost = new HttpPost(kookojaUrlPost); xxxPost.setHeader("Accept", "application/json"); xxxPost.setHeader("Content-type", "application/json"); xxxPost.setHeader("Accept-Encoding", "gzip"); xxxPost.setEntity(sendStuff); HttpResponse postResponse = httpClient.execute(xxxPost); String postText = EntityUtils.toString(postResponse.getEntity()); Log.d("debug", "rest post response was " + postText); } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } } }).start(); } </code></pre> <p>any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload