0

I wrote a service action look like

@DomainService(
        nature = NatureOfService.VIEW_REST_ONLY,
        objectType = "rest.oneService"
)
onepackage.OneService{
   @Action(semantics = SemanticsOf.SAFE)
   public List<Data> findDataByPerson(Person person, LocalDate start, LocalDate end){
   ...
   }
}

In SwaggerUI is exposed as

get /services/rest.oneService/actions/findDataByPerson/invoke  

I cannot find how to send domain objects as parameters to rest api;

How can I do that?

Thanks.

James
  • 3
  • 3

1 Answers1

0

References to domain objects use this format:

{
  "person": {
    "value": {
      "href": "http://~/objects/person.Person/123"
    }
  }
}

where person.Person is the object type (as per @DomainObject(objectType=...)) of the referenced type.

If invoking an action with a PUT (@Action(semantics=IDEMPOTENT)) or POST (@Action(semantics=NON_IDEMPOTENT)), then the above would be the body.

If invoking with a GET (@Action(semantics=SAFE)) then that json would need to be URL encoded and appended.

Further details in section 2.10 of the spec, also available online here

Dan Haywood
  • 2,215
  • 2
  • 17
  • 23
  • It can not work. My isis version is 1.16.2. As doc http://isis.apache.org/versions/1.16.2/guides/ugvro/ugvro.html#_invoking_a_get_link_eg_invoking_a_query_action It seems only work for scalar value. Thank you Dan. – James May 29 '21 at 05:27
  • I don't think that section says anything about whether reference parameters (as opposed to value parameters) work or not... it was just a demonstration of the latter. Have you tried out the example? This should work in 1.16.2 as well as 2.0.x .... at least, I don't recall making a fix. – Dan Haywood May 30 '21 at 06:02
  • Thanks to @Dan Haywood help, I have tried out the correct calling method. Just change ref to href in above instructions. For the call of SemanticsOf.SAFE, the parameters need to be assigned to x-isis-querystring. – James Jun 19 '21 at 02:22
  • Glad you figured it out, James. I'll update the answer for that typo. – Dan Haywood Jun 21 '21 at 06:58