I am trying to execute the request http://www.idmypill.com/api/id/ "api, and the JSON string I get is {"results":[],"success":false,"errors":null} This is my service handler class:
public String makeServiceCall(String url, int method, String api, byte[] pillImage) { try { // http client DefaultHttpClient httpClient = new DefaultHttpClient(); HttpEntity httpEntity = null; HttpResponse httpResponse = null; // Checking http request method type if (method == POST) { android.os.Debug.waitForDebugger(); HttpPost httpPost = new HttpPost(url); httpPost.setHeader("data = api_key", api); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addBinaryBody("files = image", pillImage); entity = builder.build(); Log.d("Entity", entity.toString()); httpPost.setEntity(entity); Log.d("post", httpPost.toString()); httpResponse = httpClient.execute(httpPost); Log.d("params", httpResponse.getParams().toString()); } httpEntity = httpResponse.getEntity(); response = EntityUtils.toString(httpEntity); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return response; }
An example python that gives a website:
Somehow, my publication format should be wrong or is it possible that they specifically want to get a .jpg image instead of a byte array? I am not familiar with Python and have been struggling with this problem for more than a week, so any help would be greatly appreciated.
Troy Zuroske Oct 21 '14 at 7:10 2014-10-21 07:10
source share