I am a new user of REST API, trying to develop an app in Flutter.
I have used CUBA REST API addon in the backend.
When I am calling data from entities, it works just fine but when I am using service then get no result. Trying from Postman and my flutter app but getting the same outcome.
Here is what I tested in POSTMAN.
- Running from Postman
http://localhost:8080/inteaccERP/rest/v2/entities/erp_OutstationDuty
this gives expected outcome,
[
{
"_entityName": "erp_OutstationDuty",
"_instanceName": "com.inteacc.erp.entity.ls.OutstationDuty-436b09df-83aa-136b-d4b2-3536d404f03c [detached]",
"id": "436b09df-83aa-136b-d4b2-3536d404f03c",
"purpose": "Visit",
"appNo": "21000050",
"appDate": "2021-10-05",
"dateFrom": "2021-09-01",
"version": 1,
"durationType": "FULL_DAY",
"tranType": "DEFAULT",
"dateTo": "2021-09-01",
"location": "DFL"
},
{
However, when I am using services, I am not getting the expected outcome.
Here is what I did for service.
Service:
@Override
@Transactional(readOnly = true)
public List<OutstationDuty> getOutstationDutyList(){
EntityManager em = persistence.getEntityManager();
return em.createQuery("select e from erp_OutstationDuty e "
, OutstationDuty.class)
.setViewName("outstationDutyBrowse-view")
.getResultList();
}
Rest Services
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c)
-->
<services xmlns="http://schemas.haulmont.com/cuba/rest-services-v2.xsd">
<service name="erp_LeaveSystemService">
<method name="leaveDateAlreadyApplied">
<param name="entity" type="com.inteacc.erp.entity.ls.LeaveApplication"/>
</method>
<method name="getOutstationDutyList">
</method>
</service>
</services>
In Postman,
http://localhost:8080/inteaccERP/rest/v2/services/erp_LeaveSystemService/getOutstationDutyList
It’s not throwing any exception but no result.
Any suggestions?