On 5 February 2015 at 14:22, Lechner Andreas <[email protected]>
wrote:

> public class DeliverableService {
>
>
>         @NotContributed
>         @MemberOrder(sequence = "2")
>         @Named("Create New Deliverable")
>         public Deliverable createNew(final @Named("DeliverableName")
> String deliverableName,
>                         final @Named("DeliverableDescription") String
> deliverableDescription,
>                         final @Named("DeliGroup") DeliGroup deliGroup
>                 ) {
>
>          }
> -------------------------------------
>
>
> now I want to call this service over the rest interface.
> I think the URL should be
>
> http://localhost:8080/restful/services/DeliverableService/actions/createNew/invoke
>
>
> I tried to test it over the "RESTClient" Plugin for Firefox with following
> JSON String
>
> JSON String:
> {
>     "deliverableName": {"value": "NAME_ABC"},
>     "deliverableDescription": {"value": "DESC_ABC"},
>     "deliGroup": {
>         "historyId": { "value": "1"},
>         "deliGroupName": { "value": "Factored" }
>     }
> }
>
> After removing the "deliGroup" part in DomainService class, and in the
> JSON String, it was working.
> {
>     "deliverableName": {"value": "NAME_ABC"},
>     "deliverableDescription": {"value": "DESC_ABC"}
> }
>
> How has the JSON String to look?
>
>

The Restful Objects spec [1] explains how to submit arguments that are
references to entity types (such as "DeliGroup"); basically you send a
"value.href" pointing to the object; see section 2.9.2.1

Something like:

{
    "deliverableName": {"value": "NAME_ABC"},
    "deliverableDescription": {"value": "DESC_ABC"},
    "deliGroup": { "value": { "href": "
http://localhost:8080/restful/objects/DeliGroup/1"; } }
}

As for submitting this JSON, it is described in section 2.10; basically:
* if the action has "safe" semantics, ie invoked via HTTP GET, then this
string is URL encoded and appended to the end of the URL (after the ?).
* if the action has "Idempotent" semantics (invoked via HTTP PUT) or
non-idempotent semantics (invoked via HTTP POST) then the JSON string is
simply the body of the request.

HTH
Dan

[1] http://restfulobjects.org/download/

Reply via email to