Api Symfony,无效数据(AppBundle\Entity\InterferenceType),应为“0”;AppBundle\实体\干预

Api Symfony,无效数据(AppBundle\Entity\InterferenceType),应为“0”;AppBundle\实体\干预,api,symfony,doctrine-orm,Api,Symfony,Doctrine Orm,我试图在我的基础上插入一行代码,从postman到带有外键的本地api,我有一个错误: “消息”:“无效数据\”1\“(AppBundle\Entity\InterventionType), 应为“AppBundle\Entity\interference\” 它指向了坏的实体,我不知道为什么。我的目标是“干预”,而教条似乎是干预型的。。。 这是我的实体: 我通过更改创建行的方式找到了一个sluton。我不直接输入干预id,而是将其传递到url: 类控制器扩展控制器 { /** *@Re

我试图在我的基础上插入一行代码,从postman到带有外键的本地api,我有一个错误:

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

它指向了坏的实体,我不知道为什么。我的目标是“干预”,而教条似乎是干预型的。。。 这是我的实体:


我通过更改创建行的方式找到了一个sluton。我不直接输入干预id,而是将其传递到url:

类控制器扩展控制器
{  
/**
*@Rest\Post(
*path=“/reports/intervention={id}”,
*name=“应用程序报告创建”
* )
*@Rest\View(状态代码=201)
*@ParamConverter(“报告”,converter=“fos\u rest.request\u body”)
*/
公共函数createAction(请求$Request,干预报告$report)
{
$em=$this->getDoctrine()->getManager();
$intervention=$this->get('doctrine.orm.entity\u manager')
->getRepository('AppBundle:Intervention')
->查找($request->get('id'));
//$report=new\DateTime($dateMaintenanceRevue);
$report->setIntervention($intervention);
$em->persist($report);
$em->flush();
返回$report;

}
我通过更改创建行的方式找到了一个sluton。我没有直接输入干预id,而是将其传递到url中:

类控制器扩展控制器
{  
/**
*@Rest\Post(
*path=“/reports/intervention={id}”,
*name=“应用程序报告创建”
* )
*@Rest\View(状态代码=201)
*@ParamConverter(“报告”,converter=“fos\u rest.request\u body”)
*/
公共函数createAction(请求$Request,干预报告$report)
{
$em=$this->getDoctrine()->getManager();
$intervention=$this->get('doctrine.orm.entity\u manager')
->getRepository('AppBundle:Intervention')
->查找($request->get('id'));
//$report=new\DateTime($dateMaintenanceRevue);
$report->setIntervention($intervention);
$em->persist($report);
$em->flush();
返回$report;

}
Add code of the controlleraps:@ORM\ManyToOne(targetEntity=“AppBundle\Entity\interferenceType”)@Cerad,我需要有这种关系,但我与一位朋友解决了这个问题。我已经更改了我的Conntroller并编辑了创建对象的方式,因此可以添加controlleraps:@ORM\ManyToOne(targetEntity)的代码=“AppBundle\Entity\InterferenceType”)@Cerad,我需要有这种关系,但我与一位朋友解决了这个问题。我已更改了我的Conntroller,并编辑了创建对象的方式,因此它是正常的