I am wondering if 'actions', 'targeted actions' and 'relationships' are simple logical divisions of services or are they treated differently at the code level. I have been working through some services tutorials and none of them mention how to create 'actions', 'targeted actions' and 'relationships'. The only info I have found specifically thus far is from docs/services.services.api.php :
* Actions are performed directly on the resource type, not a individual
* resource. The following example is hypothetical (but plausible). Say
* that you want to expose a API for the apachesolr module. One of the
* things that could be exposed is the functionality to reindex the whole
* site at apachesolr/reindex.
*
* Targeted actions acts on a individual resource. A good, but again -
* hypothetical, example would be the publishing and unpublishing of nodes
* at node/123/publish.
*
* Relationship requests are convenience methods (sugar) to get something
* thats related to a individual resource. A real example would be the
* ability to get the files for a node at node/123/files.
I am wondering if these different service types are used more as a convention for categorize services rather than being treated differently at coding level. Would a service defined under 'target_action' behave any differently if I move it to 'relationship'?
Comments
Comment #1
kylebrowning commentedIN rest serve module they are handled differently.
Targeted actions are always POST and required a 'context' in between the resource the ID and the action.
relationships are always GET's
Comment #2
monta commentedHi,
I defined a REST endpoint with targeted_actions to be called via a POST request, but this didn't work for me.
When I call http://mysite.local/api/lead I got "Services Endpoint "lead" has been setup successfully." all the time because the canonical path is empty.
My endpoint path is: api/lead (please see the export below)
In my resource.inc I have the following
// resource export
Thank you for your help,