Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.2.2 (Evans SR2), 2.3 GA (Fowler)
-
Fix Version/s: 2.4 M1 (Gosling), 2.3.1 (Fowler SR1)
-
Component/s: None
-
Labels:None
-
Reference URL:
-
Sprint:57 - Fowler Aftermath
Description
It seems that POSTing an item to an associated collection does not work as documented.
According to the Spring Data REST documentation, POST method is supported for collections, so
curl -i -X POST -H 'Content-type: text/uri-list' -d 'http://localhost:8080/artifacts/1' http://localhost:8080/collectors/1/artifacts
should add an artifact to the (yet empty) collection. Unfortunately, it does not:
HTTP/1.1 405 Method Not Allowed Server: Apache-Coyote/1.1 Allow: GET, DELETE, PATCH, PUT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Fri, 17 Apr 2015 22:54:59 GMT {"timestamp":1429311299117,"status":405,"error":"Method Not Allowed","exception":"org.springframework.web.HttpRequestMethodNotSupportedException","message":"Request method 'POST' not supported","path":"/collectors/1/artifacts"}
My entities:
@Data @Entity public class Collector { @Id @GeneratedValue private Long id; private String name; @OneToMany(mappedBy = "owner") private List<Artifact> artifacts; } @Data @Entity @Accessors(chain = true, fluent = true) public class Artifact { @Id @GeneratedValue private Long id; private String title; @ManyToOne @JoinColumn(name = "collector_id") private Collector owner; }
The complete code is on Github.