Code example for HttpPost

Methods: setEntity

0
 
	public void uploadMachine(Machine m, String uri) {
 
		try { 
			HttpClient httpclient = new DefaultHttpClient();
			HttpPost httppost = new HttpPost(uri);
			httppost.setEntity(m.makeJSON());
			HttpResponse response = httpclient.execute(httppost);
			HttpEntity entity = response.getEntity();
 
			Log.d("HTTP", "HTTP: OK");
		} catch (Exception e) {
			Log.e("HTTP", "Error in http connection " + e.toString());
		} 
 
	} 
 
	/** 
	 * Known issues: duplicate key errors when you run the same code twice with 
	 * the same id 
	 *