JSONObject / MultipartEntity 2011-11-15 12:14:26 private JSONObject createJSONObject(String name, String type, double latitude, double longitude, double altitude, String address, String webpage, String openinghours, String photo) { JSONObject jsonOuter = new JSONObject(); JSONObject jsonMain = new JSONObject(); JSONObject jsonCoordinates = new JSONObject(); try { jsonMain.put("name", name); jsonMain.put("type", type); jsonCoordinates.put("longitude", longitude); jsonCoordinates.put("latitude", latitude); jsonCoordinates.put("altitude", altitude); jsonMain.put("coordinates", jsonCoordinates); jsonMain.put("address", address); jsonMain.put("webpage", webpage); jsonMain.put("openinghours", openinghours); jsonMain.put("photo", photo); jsonOuter.put("poi", jsonMain); } catch (JSONException e) { e.printStackTrace(); } return jsonOuter; } // .... DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpPostRequest = new HttpPost(URL); MultipartEntity me = new MultipartEntity(); // poi ContentBody poi = new StringBody(jsonObjSend.toString(), "application/json", Charset.defaultCharset()); me.addPart("poi", poi); // img ContentBody img = new FileBody(image, "image/jpeg"); me.addPart("img", img); httpPostRequest.setEntity(me); // Set HTTP parameters httpPostRequest.setHeader("Accept", "application/json"); //httpPostRequest.setHeader("Content-type", "multipart/form-data"); HttpResponse response = (HttpResponse) httpclient.execute(httpPostRequest); HttpEntity entity = response.getEntity();