title: Save related entities spring data rest HAL-JSON
body: <p>I have the follow problem </p>
  
  <p>I have a basic configuration of spring data rest (Nothing fancy, nothing custom).</p>
  
  <p>Using spring-data-rest-webmvc 2.0.0 RELEASE and spring-data-jpa 1.5.0 RELEASE</p>
  
  <p>Class A</p>
  
  <pre><code>@Entity
  public class A {
  
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private int id
  
     private String name;
  
     @ManyToMany
     private List&lt;B&gt; b;
  
     // getters setters
  }
  </code></pre>
  
  <p>Class B</p>
  
  <pre><code>@Entity
  public class B {
  
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private int id
  
     private String nameb;
  
     @ManyToMany(mappedBy = "b")
     private List&lt;A&gt; a;
  
     // getters setters
  }
  </code></pre>
  
  <p>Repository A</p>
  
  <pre><code>@Repository
  @RestResource(rel = "a", path = "a")
  public interface ARepository extends PagingAndSortingRepository&lt;A, Integer&gt; {
  
  }
  </code></pre>
  
  <p>Repository B</p>
  
  <pre><code>@Repository
  @RestResource(rel = "b", path = "b")
  public interface BRepository extends PagingAndSortingRepository&lt;B, Integer&gt; {
  
  }
  </code></pre>
  
  <p>When I save an entity works fine, but I don't know how to save a relationship</p>
  
  <p>e.g. save an "A" inside a "B" using http</p>
  
  <p>This is the last thing I try from this answer <a href="https://stackoverflow.com/a/13031580/651948">https://stackoverflow.com/a/13031580/651948</a></p>
  
  <pre><code>POST http://localhost:8080/api/a
  
  {
      "name": "Name of A",
      "b": {
          "rel": "b",
          "href": "http://localhost:8080/api/b/1"
      }
  }
  </code></pre>
  
  <p>I get an 201 http code but doesn't save the entity.</p>
  
  <p>Did someone tried this already?</p>