title: api platform ManyToMany persist
body: <p>I need to persist a ManyToMany relation with api platform, but i  get a error, i've tried with cascade={&quot;persist&quot;} and with groups.</p>
  <p>When i send the request with the object, i get; Nested documents for attribute &quot;idVehicles&quot; are not allowed. Use IRIs instead.</p>
  <pre><code>{
        &quot;name&quot;: &quot;carl&quot;,
        &quot;lastName&quot;: &quot;abs&quot;,
        &quot;idVehicles&quot;: [
              {
                  &quot;license&quot;: &quot;1212121&quot;
              }
       ]
  }
  </code></pre>
  <p>here is my users entity:</p>
  <pre><code>/**
   * Users
   *
   * @ORM\Table(name=&quot;users&quot;)
   * @ORM\Entity
   * @ApiResource(
   *      attributes={&quot;pagination_enabled&quot;=false},
   *      normalizationContext={&quot;groups&quot;={&quot;users_read&quot;}},
   *      denormalizationContext={&quot;groups&quot;={&quot;users_write&quot;}},
   *  )
   */
  class Users
  {
      /**
       * @var int
       *
       * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;, nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy=&quot;SEQUENCE&quot;)
       * @ORM\SequenceGenerator(sequenceName=&quot;users_id_seq&quot;, allocationSize=1, initialValue=1)
       * @Groups({&quot;users_read&quot;, &quot;users_write&quot;})
       */
      private $id;
  
      /**
       * @var string|null
       *
       * @ORM\Column(name=&quot;name&quot;, type=&quot;string&quot;, length=128, nullable=true)
       * @Groups({&quot;users_read&quot;, &quot;users_write&quot;})
       */
      private $name;
  
      /**
       * @var string|null
       *
       * @ORM\Column(name=&quot;last_name&quot;, type=&quot;string&quot;, length=128, nullable=true)
       * @Groups({&quot;users_read&quot;, &quot;users_write&quot;})
       */
      private $lastName;
  
  
      /**
       * @var \Doctrine\Common\Collections\Collection
       *
       * @ORM\ManyToMany(targetEntity=&quot;Vehicles&quot;, mappedBy=&quot;idUsers&quot;, cascade={&quot;persist&quot;})
       * @Groups({&quot;users_read&quot;, &quot;users_write&quot;})
       */
      private $idVehicles;
  }
  </code></pre>
  <p>here is my vehicles entity:</p>
  <pre><code>/**
   * Users
   *
   * @ORM\Table(name=&quot;users&quot;)
   * @ORM\Entity
   * @ApiResource(attributes={&quot;pagination_enabled&quot;=false})
   */
  class Users
  {
      /**
       * @var int
       *
       * @ORM\Column(name=&quot;id&quot;, type=&quot;integer&quot;, nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy=&quot;SEQUENCE&quot;)
       * @ORM\SequenceGenerator(sequenceName=&quot;vehicles_id_seq&quot;, allocationSize=1, initialValue=1)
       */
      private $id;
  
      /**
       * @var string|null
       *
       * @ORM\Column(name=&quot;license&quot;, type=&quot;string&quot;, length=16, nullable=true, cascade={&quot;persist&quot;})
       * @Groups({&quot;users_read&quot;, &quot;users_write&quot;})
       */
      private $license;
  
  
  
      /**
       * @var \Doctrine\Common\Collections\Collection
       *
       * @ORM\ManyToMany(targetEntity=&quot;Users&quot;, inversedBy=&quot;idUsers&quot;)
       * @ORM\JoinTable(name=&quot;users_vehicles&quot;,
       *   joinColumns={
       *     @ORM\JoinColumn(name=&quot;id_vehicles&quot;, referencedColumnName=&quot;id&quot;)
       *   },
       *   inverseJoinColumns={
       *     @ORM\JoinColumn(name=&quot;id_users&quot;, referencedColumnName=&quot;id&quot;)
       *   }
       * )
       */
      private $idUsers;
  
  </code></pre>