I am a starter on Android platform,i just doing a porting of iOS app to Android.In iOS i used AFNetworking to access the web service .Same thing in Android i am using AsyncHttpClient and trying to communicate with the server (text json data accepted).But always getting "Internal server error" in Android,and works very well in iOS platform.Could anyone help to debug the issue.
Code:
RequestParams params = new RequestParams();
HashMap<String, String> param = new HashMap<String, String>();
param.put("Username","test123");
params.put("Message",param);
params.put("Name","ValidateUserName");
StringEntity entity = null;
JSONObject jsonParams = new JSONObject();
jsonParams.put("Message",param);
jsonParams.put("Name","ValidateUserName");
entity = new StringEntity(jsonParams.toString());
AsyncHttpClient client = new AsyncHttpClient();
Context context = this.getApplicationContext();
client.post(context,"http://10.1.124.107/sample/test/Login/Validateusername, entity, “application/json",
new AsyncHttpResponseHandler(){
@Override
public void onSuccess(String response) {
Log.d("HTTP", "onSuccess: " + response);
}
@Override
public void onFailure(Throwable e, String response) {
Log.d(“FAILURE”,e.toString());
}
});
Error :
06-05 00:34:37.895: V/FAILURE(1301): org.apache.http.client.HttpResponseException: Internal Server Error