I am posting the following JSON to Tomcat server but Tomcat server returns 400 without even calling the servlet -
[
{
"q": {
"field": "uri",
"value": "c:Data#part3"
},
"uri_pre_select": true
}
]
Inside the servlet the following code is deserializing the JSON -
// JSONObject reqJSONObj;
MyRequest[] data = gson.fromJson(reqJSONObj.toString(), MyRequest[].class);
When I remove the enclosing square brackets [ ] in the request JSON, then my servlet is called normally. This means there is something in the JSON, that is making it unacceptable to Tomcat.
But I don't have any clue why can't I post an array. Can anyone see a problem in the JSON that I am posting here ?
My mistake -
The handler method was accepting a JSONObject. When I changed the type to JSONArray it was getting called by Tomcat.