意外的响应代码415

时间:2015-12-06 21:55:20

标签: java android json android-fragments jersey-2.0

我面临一些问题,要发送凌空邮件请求将json从android app传递给java restful service错误发生:“Basic Network Unexpected response code 415”我的代码的快照就在这里。如果有人知道解决方案,请帮助。

@POST
        @Path("/feedback")
        @Consumes(MediaType.APPLICATION_JSON)
        public void postFeedback(feedbackModel fbkModel){

        f_name = fbkModel.getName();
        f_mobile = fbkModel.getMobile().toString();
        f_description = fbkModel.getDescription();
        f_rating = fbkModel.getRating();


        dataService.insertFeedback(f_name, f_mobile, f_description, f_rating);
        }

    //Android app Method to create Json Obj... Volley Json Request...

        private void createJsonObj(){
    String url = "http://192.168.23.1:8080/RESTfulExample/rest/file/feedback";
        showProgressDialog();

        StringRequest stringRequest = new StringRequest(Request.Method.POST,
        url,
        new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
        Log.d(TAG, response.toString());
        //msgResponse.setText(response.toString());
                            Toast.makeText(getBaseContext(),response.toString(),Toast.LENGTH_LONG).show();
        hideProgressDialog();
        }
        }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
        VolleyLog.d(TAG, "Error: " + error.getMessage());
        hideProgressDialog();

        NetworkResponse networkResponse = error.networkResponse;
        if (networkResponse != null) {
    Log.e("Volley", "Error. HTTP Status Code:"+networkResponse.statusCode);
        }

        if (error instanceof TimeoutError) {
        Log.e("Volley", "TimeoutError");
        }else if(error instanceof NoConnectionError){
        Log.e("Volley", "NoConnectionError");
        } else if (error instanceof AuthFailureError) {
        Log.e("Volley", "AuthFailureError");
        } else if (error instanceof ServerError) {
        Log.e("Volley", "ServerError");
        } else if (error instanceof NetworkError) {
        Log.e("Volley", "NetworkError");
        } else if (error instanceof ParseError) {
        Log.e("Volley", "ParseError");
        }

        }
        }) {


        //   * Passing some request headers


        @Override
        protected Map<String, String> getParams() throws AuthFailureError{
        Map<String, String> params = new HashMap<String, String>();
        params.put("name", f_name);
        params.put("mobile", f_mobile);
        params.put("description", f_description);
        params.put("rating",f_ratVel );

        return params;
        }

        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
        HashMap<String, String> headers = new HashMap<String, String>();
    // headers.put("Content-Type", "application/json; charset=utf-8");
        return headers;
        }


        };

        requestQueue.add(stringRequest);

        }

0 个答案:

没有答案