http 415 error

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

http 415 error
This post has NOT been accepted by the mailing list yet.
Dear everyone:
      My project use spring/hibernate and struts run on Tomcat 7,and i use restlet 2.3.5 to build restful interface to communicate with android application.
      The restlet resource i wrote like the follwing:
      @Post ("json")
        public Object getAllStations(){
             return gson.toJson(map);
       And our android application use asynchttpclient sent post request.And the android code is like the fellowing:
       syncHttpClient client = new AsyncHttpClient();, map, new JsonHttpResponseHandler() {
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                try {
                    if ("1".equals(response.getString("status"))) {
                } catch (JSONException ex) {
                    Log.e(TAG, "JSON Error");
       If i start my application and use Firefox addon "restclient" to test post request,and everythin go well,i can see the response content type is application/json, after the Android app runs well ,but if i use Android app to sent the post request first time after the application started,the http 415 error occur and i use firefox sent post request,and found the response content type is text/plain.
      I don't know why i use annoation to configure the return type is json but why it didn't work on Android app if the application was started.Except i use firefox to sent the post request first time.I try a lots of way but the error was still there.