Hi!
We have created services to be open for the rest API. Many of these services have methods that take in java.time objects, primarly LocalDate
, I have tried to implement this in the following way:
Interface
public interface MyService {
String NAME = "app_MyService";
void method(LocalDate date);
}
Implementation
@Service(MyService.NAME)
public class MyServiceBean implements MyService {
public void method(LocalDate date) {
...
}
}
rest-services.xml
<service name="app_MyService">
<method name="method">
<param name="date" />
</method>
</service>
When I try to call this service with payload:
{
"date": "2020-10-01"
}
It doesn’t work. I get a 400 back with message Invalid parameter value for date
.
The logs show a com.google.gson.JsonSyntaxException: java.lang.IllegalStateException
: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
I have also tried to specify the param name in rest-services.xml
with:
<param name="date" type="java.time.LocalDate" />
But still no success.
If I simply change java.time.LocalDate
to java.util.Date
everything works as expected. Is Java 8 Time Module supported in the rest-api addon?