Code example for HttpPost

Methods: setEntityaddHeadersetParams

0
			// Set verifier 
			HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
		} 
         
		// Create HTTP/POST request with a JSON entity containing the request 
		HttpPost request = new HttpPost(serviceUri);
		HttpParams params = new BasicHttpParams();
		HttpConnectionParams.setConnectionTimeout(params, getConnectionTimeout());
		HttpConnectionParams.setSoTimeout(params, getSoTimeout());
		 
		HttpProtocolParams.setVersion(params, PROTOCOL_VERSION);
		request.setParams(params);
		 
		 
		if (sessionId != null)
			request.addHeader("X-GEOREMINDME-SESSION", sessionId);
		 
		HttpEntity entity;
		try 
		{ 
			entity = new JSONEntity(jsonRequest);
		} 
		catch (UnsupportedEncodingException e1)
		{ 
			throw new JSONRPCException("Unsupported encoding", e1);
		} 
		request.setEntity(entity);
		 
		try 
		{ 
			// Execute the request and try to decode the JSON Response 
			long t = System.currentTimeMillis();
			HttpResponse response = httpClient.execute(request);
			t = System.currentTimeMillis() - t;
			Log.d("json-rpc", "Request time :" + t);
			String responseString = EntityUtils.toString(response.getEntity());
			responseString = responseString.trim();
			JSONObject jsonResponse = new JSONObject(responseString);
Contextual code suggestions in your IDE  Get Codota for Java