Code example for ByteArrayEntity

Methods: setContentEncoding, setContentType

0
		return data;
	} 
 
	private void postWithoutReturn(String function, JSONObject content) throws IOException, ClientProtocolException {
		HttpPost postRequest = new HttpPost(getBaseURL() + function);
		ByteArrayEntity entity = new ByteArrayEntity(content.toString().getBytes("UTF8"));
		entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
		entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_ENCODING, HTTP.UTF_8));
		postRequest.setEntity(entity);
		client.execute(postRequest);
	} 
 
	/* 
	private JSONObject put(String function, JSONObject content) throws IOException, ClientProtocolException, JSONException { 
		HttpPut putRequest = new HttpPut(getBaseURL() + function); 
		ByteArrayEntity entity = new ByteArrayEntity(content.toString().getBytes("UTF8")); 
		entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); 
		entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_ENCODING, HTTP.UTF_8)); 
		putRequest.setEntity(entity); 
		HttpResponse response = client.execute(putRequest); 
		JSONObject data = createJSONObject(response);