Volley Not Parsing 404 response

后端 未结 2 2137
旧时难觅i
旧时难觅i 2021-02-19 06:49

Volley returns an error when a 404 response is returned from the server even if that 404 response contains json based error codes. It does not parse the 404 response which cont

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-19 07:48

    If someone want to add the Body/Headers to the POST call then add the code below

    @Override
    public HashMap getHeaders() throws AuthFailureError {
        HashMap params = new HashMap<>();
        params.put("apikey", Constants.apiKey);
        params.put("env", Constants.enviroment);
        params.put("Content-Type", "application/json");
        return params;
    }
    
    @Override
    public byte[] getBody() throws AuthFailureError {
        return gson.toJson(user).getBytes();
    }
    

    Where user is the Object you can pass to the Body.

提交回复
热议问题