Volley post request 415 error2

1.4k Views Asked by At
   JsonObjectRequest jor = new JsonObjectRequest(JsonObjectRequest.Method.POST, url, json, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            Log.d("glamour", response.toString());
            Toast.makeText(WelcomeActivity.this, "onResponse: " + response.toString(), Toast.LENGTH_SHORT).show();
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            //Log.e("glamour", error.getMessage());
            error.printStackTrace();
            Toast.makeText(WelcomeActivity.this, "onErrorResponse: " + error.getMessage(), Toast.LENGTH_SHORT).show();
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> headers = new HashMap<>();
            headers.put("Accept", "application/json");
            headers.put("Content-Type", "application/json; charset=UTF-8");
            return headers;
        }
    };

    mQueue.add(jor);

erro info : BasicNetwork.performRequest: Unexpected response code 415 for http://192.168.1.103:8080/appapi/customer/login/v3

how to fix it? please help.

1

There are 1 best solutions below

1
On BEST ANSWER

Http status code 415

415 Unsupported Media Type The request entity has a media type which the server or resource does not support. For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.

from List of HTTP status codes

So check your media type declaration both at endpoint and client.