I am trying to make a rest api call but keeps getting 400 Bad Request
. From the logs, it seems that there is a problem with one of the LocalDate
fields of my POJO.
My POJO:
public class MyObj implements Serializable {
private Long id;
private String remark;
private LocalDate someDate;
...other fields, getter and setter
In my main()
MyObj myObj = new MyObj();
myObj .setRemark("My test case");
myObj .setSomeDate( LocalDate.now());
...
WebResource webResource = client
.resource("my_url");
webResource
.header("apikey", "mykey")
.accept("application/json")
.type("application/json")
.post(MyObj.class, myObj );
Running the above code I get the following error:
Bad Request: JSON parse error: Expected array or string.; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Expected array or string.
at [Source: (PushbackInputStream); line: 1, column: 159] (through reference chain: com.xxx.MyObj["someDate"])
Any idea why the above happened?