Data type - REST API

Hi
I am using REST API add-on to execute a service method and have some questions on date date type.

I am sending DateTime parameter value from Flutter and in my REST API Backend, using java.util.Date parameters. However, when I read the exception below it looks like there are some extra characters received by the REST API as below.

astSecurityFilter - REST API request [***xcNE] GET http://43.224.118.54:8080/myAPP/rest/v2/services/erp_LeaveSystemService/createLeaveApplication?employeeCode=000171&leaveTypeCode=CL&startDate=2022-05-09%2000:00:00.000&endDate=2022-05-10%2000:00:00.000&durType=fullDay&note=TEST 50.50.50.2
2022-04-10 12:28:46.688 DEBUG [http-nio-8080-exec-290/myAPP/000171] com.haulmont.addon.restapi.api.rest.RestAPIDispatcherServlet - GET "/inteaccERP/rest/v2/services/erp_LeaveSystemService/createLeaveApplication?employeeCode=000171&leaveTypeCode=CL&startDate=2022-05-09%2000:00:00.000&endDate=2022-05-10%2000:00:00.000&durType=fullDay&note=TEST", parameters={masked}
2022-04-10 12:28:46.859 ERROR [http-nio-8080-exec-290/myAPP/000171] com.haulmont.addon.restapi.api.config.RestServicesConfiguration - Method not found. Service: erp_LeaveSystemService, method: createLeaveApplication, argument types: [class java.lang.String, class java.lang.String, class java.util.Formatter$DateTime, class java.util.Formatter$DateTime, class java.lang.String, class java.lang.String]
2022-04-10 12:28:46.859 INFO  [http-nio-8080-exec-290/myAPP/000171] com.haulmont.addon.restapi.api.controllers.RestControllerExceptionHandler - RestAPIException: Service method not found, erp_LeaveSystemService.createLeaveApplication(employeeCode,leaveTypeCode,startDate,endDate,durType,note)
2022-04-10 12:28:46.953 DEBUG [http-nio-8080-exec-290] com.haulmont.addon.restapi.api.rest.RestAPIDispatcherServlet - Completed 404 NOT_FOUND

Here is the Server siide codes:

REST Service:

<method name="createLeaveApplication">
        <param name="employeeCode" type="java.lang.String"/>
        <param name="leaveType" type="java.lang.String"/>
        <param name="startDate" type="java.util.Date"/>
        <param name="endDate" type="java.util.Date"/>
        <param name="durType" type="java.lang.String"/>
        <param name="note" type="java.lang.String"/>
    </method>

ServiceBean:

@Override
    @Transactional
    public void createLeaveApplication(String employeeCode, String leaveTypeCode, Date startDate, Date endDate, String durType, String note){

Thanks for any help suggesting a fix.

Hi Mortoza,

First, your parameter names do not match: leaveType in registered service method, leaveTypeCode in the request.

Second, you should use the ISO format for passing date/time values, for example 2022-04-12T18:56:32.

1 Like

Thank you Konstantin.
LeaveType/LeaveTypeCode - I was doing so many ways to try, I copied it from wrong place…Thanks for mentionting.

I’ll try using ISO date format as suggested. From REST API, which date format should I use sql.date, util.date?

Another related question, what is the data type we should use for saving images from a client app to REST backend? The image data field in the Entity is ByteArray but there is no such data type in JSON.

Hi @krivopustov, I still facing that error: DateTimaParseException: Text '2022-03-29' could not be parsed at index 10. I’ve tried this patterns: yyyy-MM-ddTHH:mm:ss, yyyy-MM-dd HH:mm:ss.SSS and yyyy-MM-dd, they too throws this error. Could you please suggest patterns for @Temporal(TemporalType.DATE). and
@Temporal(TemporalType.TIMESTAMP)

Hi @maihanov96
Please provide your service method signature and its configuration in rest-services.xml.