Android Volley gives me 400 error

后端 未结 12 2129
借酒劲吻你
借酒劲吻你 2020-12-11 00:28

I\'m trying to make a POST request to my API and it works in Postman (I get a valid JSON object), but not using Volley. With the follo

12条回答
  •  伪装坚强ぢ
    2020-12-11 00:59

    400 error is because Content-Type is set wrong. Please do the following.

    1. GetHeader function should be as

          @Override
          public Map getHeaders() throws AuthFailureError {
      
              Map param = new HashMap();
      
              return param;
          }
      
    2. Add this new override function.

          @Override
          public String getBodyContentType() {
              return "application/json";
          }
      

提交回复
热议问题