In volley library giving com.android.volley.ServerError

后端 未结 6 1493
死守一世寂寞
死守一世寂寞 2021-02-09 05:30

I try to login in my application, when I try to call API using volley library, it\'s giving com.android.volley.ServerError and response code 400.

final String u         


        
6条回答
  •  北海茫月
    2021-02-09 05:57

    This error can mean BAD REQUEST, check the headers you are sending. Overring the getHeaders() method you can send the right headers.

    @Override
    public Map getHeaders() throws AuthFailureError {
            return (headers != null || headers.isEmpty()) ? headers : super.getHeaders();
        }
    

    Also, usually the WebServices need application/json headers, as follow:

    headers.put("Accept","application/json");
    headers.put("Content-Type","application/json");
    

提交回复
热议问题