0

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
Pragnesh Ghoda シ
  • 8,318
  • 3
  • 25
  • 40
SMS
  • 558
  • 1
  • 9
  • 22
  • Is your local server started? Also, i guess that for local machine servers, the port number should be specified. Something like `http://10.1.124.107:8080/sample.....`? – ngrashia Jun 05 '14 at 05:00
  • But in iOS app we are using the same URL and it works fine without specifying the port,and also the server is up and working. – SMS Jun 05 '14 at 05:03
  • I have not worked in IOS. So i am not sure. But in android, we usually give the port. Also, please check if the necessary proxies are enabled – ngrashia Jun 05 '14 at 05:05
  • try to use with port no. Try with Nisha's comment. – nilkash Jun 05 '14 at 05:10
  • Hey Buddy...Try to access your URL from browser..if it works there may be problem with your code.. if doesn't there may be issue with the server...for more details about that error read this article... [http://pcsupport.about.com/od/findbyerrormessage/a/500servererror.htm] – Pragnesh Ghoda シ Jun 05 '14 at 05:11
  • Thanku, the error was due to json data conversion. – SMS Jun 06 '14 at 06:46

0 Answers0