The rest API is failing with 400 Bad request with below response
javax.xml.bind.JAXBException - with linked exception: [org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 0 of ]
Below is my code,
API Resource
@GET
@Path("/getTeams")
@Produces(MediaType.APPLICATION_JSON)
public Response getTeamList(final TeamSearchRequest teamSearchRequest, @Context UriInfo uriInfo) {
//Business
}
Request Class
@XmlRootElement(name = "teamSearchRequest")
public class TeamSearchRequest {
private String searchText;
private String searcherTeamId;
public TeamSearchRequest(){}
//setters and getters
}
API URI - http://localhost:8080/letsplay/team/getTeams
API Request Body -
{
"teamSearchRequest": {
"searchText": "Mumbai",
"searcherTeamId": "1"
}
}
Note - I have already checked all the similar questions in SO.
Any suggestions is most appreciated.
JSONObject
as the method argument instead ofTeamSearchRequest
and then do ajsonObject.getJSONObject("teamSearchRequest")
to get the desired values. – Prathap