- From: Tomasz Pluskiewicz via GitHub <sysbot+gh@w3.org>
- Date: Mon, 16 Oct 2017 19:10:07 +0000
- To: public-hydra-logs@w3.org
As a followup to the [comment above](#issuecomment-336729288), here are [Pavlik's snippets](#issuecomment-336670989) rewritten by attaching the operation to IRI template. Nothing changes if the operation is `POST` on the collection itself: ```json { "@context": "/api/context.jsonld", "@id": "/api", "@type": "hydra:EntryPoint", "collection": [ { "@id": "/api/events", "title": "List of events", "@type": "hydra:Collection", "manages": { "property": "rdf:type", "object": "schema:Event" }, "operation": { "@type": ["hydra:Operation", "schema:CreateAction"], "title": "Create new event", "method": "POST", "expects": "schema:Event" } } ] } ``` If service chooses to use PUT not POST to create, it would link to the resource to PUT to and have the operation on that ``` json { "@context": "/api/context.jsonld", "@id": "/api", "@type": "hydra:EntryPoint", "collection": [ { "@id": "/api/events", "title": "List of events", "@type": "hydra:Collection", "manages": { "property": "rdf:type", "object": "schema:Event" }, "hydra:addMember": { "@id": "/api/events/new", "operation": { "@type": ["hydra:Operation", "schema:CreateAction"], "title": "Create new event", "method": "PUT", "expects": "schema:Event" } } } ] } ``` If the IRI of the resource used to create isn't known an IRITemplate can be used without changing the above much: ``` json { "@context": "/api/context.jsonld", "@id": "/api", "@type": "hydra:EntryPoint", "collection": [ { "@id": "/api/events", "title": "List of events", "@type": "hydra:Collection", "manages": { "property": "rdf:type", "object": "schema:Event" }, "hydra:addMember": { "@type": "IriTemplate", "template": "/api/events/{slug}", "mappings": [{ "variable": "slug" }], "operation": { "@type": ["hydra:Operation", "schema:CreateAction"], "title": "Create new event", "method": "PUT", "expects": "schema:Event" } } } ] } ``` The only difference is that instead of a concrete `"@id"`, the target is an `hydra:IrITemplate`. To perform the request first the template needs to be resolved. -- GitHub Notification of comment by tpluscode Please view or discuss this issue at https://github.com/HydraCG/Specifications/issues/141#issuecomment-337000844 using your GitHub account
Received on Monday, 16 October 2017 19:10:09 UTC