isis

how to invoke rest api with domain object parameter


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.


Solution

  • 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