Hello, guys, I'm developing an app in the Android Studio IDE and I'm having trouble connecting to my webservice. I'm getting the error: D / response: {"success": "false", "message": "The JSONObject text must begin with '{' at character 1 of location = 25"}, follow the code. Does anyone know how I can solve this problem? Thank you in advance.
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("http://MY_HOST");
httpPost.setHeader("Content-Type","application/json;charset=UTF-8");
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("location","25"));
try {
httpPost.setEntity(new UrlEncodedFormEntity(pairs, "UTF-8"));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
serverData = EntityUtils.toString(httpEntity);
Log.d("response", serverData);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}