HTTP 400 (bad request) for logical error, not malformed request syntax

后端 未结 8 976
生来不讨喜
生来不讨喜 2020-12-02 09:11

The HTTP/1.1 specification (RFC 2616) has the following to say on the meaning of status code 400, Bad Request (§10.4.1):

The request could not be unde

8条回答
  •  离开以前
    2020-12-02 09:30

    In my case:

    I am getting 400 bad request because I set content-type wrongly. I changed content type then able to get response successfully.

    Before (Issue):

    ClientResponse response = Client.create().resource(requestUrl).queryParam("noOfDates", String.valueOf(limit))
                    .header(SecurityConstants.AUTHORIZATION, formatedToken).
    header("Content-Type", "\"application/json\"").get(ClientResponse.class);
    

    After (Fixed):

    ClientResponse response = Client.create().resource(requestUrl).queryParam("noOfDates", String.valueOf(limit))
                    .header(SecurityConstants.AUTHORIZATION, formatedToken).
    header("Content-Type", "\"application/x-www-form-urlencoded\"").get(ClientResponse.class);
    

提交回复
热议问题