title: Create entity with relation on a POST request with Api Platform
body: <p>I want to send a post request that creates an entity and also other entities from one-to-many relations. I have a bet_question, that can be related to many bet_choices and many bet_points, and I want to create a bet_question with some bet_choices and bet_points in the same request. I used serialization groups like written in the doc, but I still get this error : <strong>Nested documents for attribute "betPoints" are not allowed. Use IRIs instead.</strong></p>
  
  <p>Here is what I send (with <code>accept: application/json</code> in header) :</p>
  
  <pre class="lang-json prettyprint-override"><code>{
     "question":"Will team A win ?",
     "betPoints":[
        {
           "value":"100"
        },
        {
           "value":"200"
        }
     ],
     "betChoices":[
        {
           "name":"Yes",
           "odds":2
        },
        {
           "name":"No",
           "odds":2
        }
     ],
     "fixture":"/api/fixtures/23"
  }
  </code></pre>
  
  <p>And here is my entities :</p>
  
  <p><strong>Truncated Entity BetQuestion</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>/**
   * @ApiResource(attributes={
   *         "normalizationContext"={"groups"={"bet:read"}},
   *         "denormalizationContext"={"groups"={"bet:write"}}
   *     })
   * @ORM\Entity(repositoryClass="App\Repository\BetQuestionRepository")
   */
  class BetQuestion
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       * @Groups({"bet:read"})
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255)
       * @Groups({"bet:read", "bet:write"})
       */
      private $question;
  
      /**
       * @ORM\OneToMany(targetEntity="App\Entity\BetPoint", mappedBy="betQuestion", cascade={"persist"})
       * @Groups({"bet:read", "bet:write"})
       */
      private $betPoints;
  
      /**
       * @ORM\OneToMany(targetEntity="App\Entity\BetChoice", mappedBy="betQuestion", cascade={"persist"})
       * @Groups({"bet:read", "bet:write"})
       */
      private $betChoices;
  
      /**
       * @ORM\OneToOne(targetEntity="App\Entity\Fixture", inversedBy="betQuestion", cascade={"persist", "remove"})
       * @Groups({"bet:read", "bet:write"})
       */
      private $fixture;
  </code></pre>
  
  <p><strong>Truncated Entity BetPoint</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>/**
   * @ApiResource()
   * @ORM\Entity(repositoryClass="App\Repository\BetPointRepository")
   */
  class BetPoint
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       * @Groups({"bet:read"})
       */
      private $id;
  
      /**
       * @ORM\Column(type="integer")
       * @Groups({"bet:read", "bet:write"})
       */
      private $value;
  
      /**
       * @ORM\ManyToOne(targetEntity="App\Entity\BetQuestion", inversedBy="betPoints")
       * @ApiSubresource(maxDepth=1)
       */
      private $betQuestion;
  </code></pre>
  
  <p><strong>Truncated Entity BetChoice</strong></p>
  
  <pre class="lang-php prettyprint-override"><code>/**
   * @ApiResource()
   * @ORM\Entity(repositoryClass="App\Repository\BetChoiceRepository")
   */
  class BetChoice
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       * @Groups({"bet:read"})
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255)
       * @Groups({"bet:read", "bet:write"})
       */
      private $name;
  
      /**
       * @ORM\Column(type="boolean")
       * @Groups({"bet:read"})
       */
      private $value = false;
  
      /**
       * @ORM\Column(type="float")
       * @Groups({"bet:read", "bet:write"})
       */
      private $odds;
  
      /**
       * @ORM\ManyToOne(targetEntity="App\Entity\BetQuestion", inversedBy="betChoices")
       * @Groups({"bet:write"})
       */
      private $betQuestion;
  </code></pre>
  
  <p>Can you help me find what I am doing wrong please ?</p>