I'm having trouble posting a JSON array to a Spring Boot @RequestMapping Rest controller. Get 400 Bad Request. Any suggestions how to correct?
JQuery .ajax post
var sData = ["15957.028", "16356.175", "16937.155", "17564.315", "17942.480", "17760.259", "16572.306", "16746.408", "17339.681", "17946.216"]
$.ajax({
type: "POST",
url: "/regression",
data: JSON.stringify({"sdata": sData}),
contentType: 'application/json',
headers: { 'X-CSRF-Token': token },
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown, jqXHR.error());
},
success: function(){
}
});
@RestController
@RequestMapping(value="/regression", method = RequestMethod.POST)
public HashMap<String, String> results(@RequestBody List<String> series ) {
HashMap<String, String> results = new HashMap<String, String>();
return results;
}
Response Error
responseText: "{"timestamp":1424834682223,"error":"Bad Request","status":400,"message":""}"
data: sData- guido