public int postWithArgs(String targetURL, ArrayList<NameValuePair> pairs) { int statusCode = 0; try { HttpPost post = new HttpPost(baseURL() + targetURL); //Set headers manually because Android doesn't seem to care to post.addHeader("X-Spree-Token", this.apiKey); if (pairs != null) { post.setEntity(new UrlEncodedFormEntity(pairs, "UTF-8")); Log.d("RESTConnector.putWithArgs", "added pairs"); } HttpResponse response = client.execute(post); StatusLine statusLine = response.getStatusLine(); statusCode = statusLine.getStatusCode(); if (statusCode == 200 || statusCode == 201 || statusCode == 202) { HttpEntity entity = response.getEntity(); String content = EntityUtils.toString(entity); } else { Log.d("RESTConnector.genericRequest", "Response not 200, Status: " + statusCode);