0
Hello, folks I am developing an app in the Android Studio IDE and am having problems connecting to my webservice. I am receiving error: D/Answer: {"Success":"false","message":"A Jsonobject text must Begin with '{' at Character 1 of Location=25"}, follows the code. Does anyone know how I can solve this problem? Thank you very much.
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();
}
I only replied at first because I couldn’t add comments ><
– Jhonatan Pereira
I am receiving this message in Logcat. The problem is that when I convert to Json Object before sending it does not set as parameter to '{'.
– Ari Ferreira Junior
Add your JSON received from Webservice to the question for ease of understanding.
– Jhonatan Pereira
See if this can help: stackoverflow.com/questions/19399135/a-jsonobject-text-must-Begin-with-error
– Jhonatan Pereira