Re: [Specifications] CreateAction with HTTP PUT

I think we should go with one step at a time, while we have dedicated issue for #134 here we can start with a [UC#5 Creating a new event](https://github.com/HydraCG/Specifications/blob/master/drafts/use-cases/5.creating-new-event.md) and just use PUT instead of POST.
Looking at [UC#1 Entry point](https://github.com/HydraCG/Specifications/blob/master/drafts/use-cases/1.entry-point.md), as I suggested in https://github.com/HydraCG/Specifications/issues/3#issuecomment-336635276 the definition of action should stay almost the same. Currently we have

```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 choses to use PUT not POST to create, it would have something like

```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": "PUT",
        "expects": "schema:Event",
        "targetTemplate": {
          "@type": "hydra:IriTemplate",
          "hydra:template": "/api/events/{?uuid}",
          "hydra:mapping": {
            "hydra:variable": "uuid",
            "hydra:property": "id:uuid",
            "hydra:required": true
          }
        }
      }
    }
  ]
}
```

Once we have at least one possible solution for simple case like this, we can see if it still works with more complex case (like relating existing resources), but I see benefits with starting from simple case.

-- 
GitHub Notification of comment by elf-pavlik
Please view or discuss this issue at https://github.com/HydraCG/Specifications/issues/141#issuecomment-336670989 using your GitHub account

Received on Saturday, 14 October 2017 22:11:29 UTC