Php Symfony-反序列化包含多个属性的实体

Php Symfony-反序列化包含多个属性的实体,php,symfony,doctrine,Php,Symfony,Doctrine,我有一个实体“Eleve”: 当我想通过Http Post发送此Json文件时: [ { "nom":"EleveName", "prenom":"EleveFirstName", "promotion":1 } ] 我有以下错误: “消息”:“无效数据\”1“(整数),应为“AppBundle\Entity\Promotion\” 我认为这意味着他想要一个“升级”实体,而不是一个整数。 是否可以像在json中那样只提供促销id,

我有一个实体“Eleve”:

当我想通过Http Post发送此Json文件时:

[
    {
        "nom":"EleveName",
        "prenom":"EleveFirstName",
        "promotion":1
    }
]
我有以下错误:

“消息”:“无效数据\”1“(整数),应为“AppBundle\Entity\Promotion\”

我认为这意味着他想要一个“升级”实体,而不是一个整数。 是否可以像在json中那样只提供促销id,还是强制我传递整个实体

我使用FosRestBundle来执行我的http请求,并使用条令来处理数据库。 我真的不知道如何处理这个问题,我在网上没有找到任何关于它的信息。也许你知道我在哪里可以找到帮助我

有人能帮我吗

谢谢

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;

/**
 * @ORM\Entity
 * @ORM\Table()
 */
class Promotion
{

/**
 * @ORM\Column(type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 * 
 * @Serializer\Groups({"get"})
 */
private $id;

/**
 * @ORM\Column(type="string", length=100)
 * 
 * @Serializer\Groups({"get"})
 */
private $title;

/** 
 * @ORM\Column(type="integer") 
 * 
 * @Serializer\Groups({"get"})
 */
private $annee;

/**
 * @ORM\ManyToOne(targetEntity="Formation", cascade={"all"}, fetch="EAGER")
 * 
 * @Serializer\Groups({"formations"})
 */
private $formation;

/**
 * @ORM\OneToMany(targetEntity="Eleve", mappedBy="promotion", cascade={"persist"})
 * 
 * @Serializer\Groups({"eleves"})
 */
private $eleves;


public function getId()
{
    return $this->id;
}

public function getTitle()
{
    return $this->title;
}

public function setTitle($title)
{
    $this->title = $title;

    return $this;
}

public function getAnnee()
{
    return $this->annee;
}

public function setAnnee($annee)
{
    $this->annee = $annee;

    return $this;
}

public function getFormation()
{
    return $this->formation;
}

public function setFormation($formation)
{
    $this->formation = $formation;

    return $this;
}

public function getEleves()
{
    return $this->eleves;
}

public function setEleves($eleves)
{
    $this->eleves = $eleves;

    return $this;
}
}
[
    {
        "nom":"EleveName",
        "prenom":"EleveFirstName",
        "promotion":1
    }
]