Received feedback from colleagues today.
Caused by: feign.FeignException$BadRequest: [400 Bad Request] during
[POST] to
[http://gateway-v2-se-java/meta/metaClass/metaGetAllChildren?className=Dialog¤tClass=false]
[MetaClassRemote#metaGetAllChildren(String,Boolean)]: [<!doctype
html>HTTP Status 400 – Bad<br/> Request
The source code of the problem:
@RequestMapping(value = "/test", headers = "{Content-Type=application/json;charset=UTF-8}", method = RequestMethod.POST)
Resp<List<CommonVo>> getChildren(@RequestParam("name") String name, @RequestParam(required = false, value = "currentName") Boolean currentName);
There are many reasons for the 400 bad request caused by the feign call, and the following are generally encountered:
- The client request parameters are inconsistent with the server request parameters.
- The requested header is too large or the parameter is too large
- There is a problem with the request header itself
The corresponding solutions are:
4. Modify the source code to make the request parameters consistent.
5. Set the following parameters:
server:
port: 8080
max-http-header-size: 102400 #调大服务提供者的header参数(微服务较多 不太适用)
- The problem of the header itself is usually included in the previous solution, but there are other reasons.
For example, the problem I encountered was that the header parameter format in the code was wrongly written.
Note the double quotes here, the correct way of writing should be:
headers = {
"Content-Type=application/json;charset=UTF-8"}
If there is a problem, we still have to check the source code first.