Code example for StringEntity

Methods: setContentType

0
 
			HttpPost httpPost = new HttpPost(url);
			httpPost.setHeader("Content-type", "application/json");
 
			try { 
				StringEntity se = new StringEntity(json, "UTF-8");
				se.setContentType("application/json");
				httpPost.setEntity(se);
 
				HttpResponse response = httpClient.execute(httpPost);
				HttpEntity entity = response.getEntity();
				responseJSON = new JSONObject(EntityUtils.toString(entity));
 
				// TODO process response 
				Log.d("C2BClient", "sent data to server: JSON=" + json
						+ " RESULT=" + responseJSON.toString());
			} catch (Exception e) {
				e.printStackTrace();
			} 
			COMMUNICATION_RUNNING = false;
Stop searching for code, let great code find you!  Add Codota to your java IDE