Code example for StringEntity

Methods: setContentType

0
		 
		Gson gson = new Gson();
		String jsonBody = gson.toJson(body);
		 
		try { 
			StringEntity entity = new StringEntity(jsonBody, "UTF-8");
			entity.setContentType("application/json");
			 
			httpPost.setEntity(entity);
			return httpClient.execute(httpPost);
		} catch (UnsupportedEncodingException e) {
			return null; 
		} catch (ClientProtocolException exception) {
			return null; 
		} catch (IOException exception) {
			return null; 
		} 
	} 
	 
	@Override 
Connect your IDE to all the code out there  Get Codota for Java