I am trying to upload a string to server by post.. This is my code..
String URL = "http://myUrl/add?user_id="+user_id
+ "&text=" + text
+ "&type=" + type;
URL = URL.replaceAll(" ", "%20");
URL = URL.replaceAll("\n", "%0A");
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(URL);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
String result = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
This code is working when i am uploading a small string.. but when i am trying to send large string (more than 2 lines) for example.. it doesn't work.. Any suggestions?
Thank you :)