Bad Request 400 -@RequestBody

2019-08-30 11:09发布

问题:

I am trying to send JSON :

{"source": "CED:100973626887874,CED:77148046400112,CED:222222222222201"}` 

and my Controller is as below:

@RequestMapping(value = "/multipleMember/list", method =RequestMethod.POST)
@ResponseBody
public List<MemberDetail> getMultipleMemberList(
        @RequestBody String memberList) {
    return memberServiceDelegate.getMultipleMemberList(memberList);
}

But I am getting bad request 400 : The request sent by the client was syntactically incorrect

回答1:

perhaps your json object will need an object named memberList

{"memberList": "CED:100973626887874,CED:77148046400112,CED:222222222222201"}


回答2:

I believe you need to wrap your json with { } in order to indicate it is an object.

{
"source": "CED:100973626887874,CED:77148046400112,CED:222222222222201" 
}