It may be a basic question related to Spring Rest service Post request
Below is my Controller mapping code:
@RequestMapping(value = "test", method = RequestMethod.POST)
@ResponseBody
public String addFruits(@RequestBody RequestWrapper fruits) {
// ...
System.out.println("test");
return null;
}
Below is the RequestWrapper class:
public class RequestWrapper{
List<String> ids;
String languageCode;
...
}
Now if in advanced Chrome rest client, with content-type as application/json if I post the following request :
["ids": [{ "1","2","3","4"}]
,
"languageCode" : "en_US"
]
I get the following error:
Error 400: SRVE0295E: Error reported: 400
Any clue as to where I am going wrong?
The issue was due to an incorrect JSON format in the actual question.
With due help from Soitirios Delimanolis and Alejandro Agapito Bautista could correct the json format and the code worked.
The correct json format is:
{ "ids": [ 1, 2, 3, 4 ], "languageCode": "en_US" }
Also learnt from Alejandro Agapito Bautista's the json validation link jsonlint.com