Symfony / api-platform PATCH NotEncodableValueException: "Syntax error"



我使用api平台,GET和POST工作很好,我需要修补"isFinished;在我的实体中,但我有一个错误:请求未捕获的PHP异常Symfony\Component\Serializer\Exception\NotEncodableValueException:"语法错误";

你认为我的实体配置不好吗?谢谢你的帮助。

/**
* @ApiResource()
* @ORMEntity(repositoryClass=CurrentJourneyRepository::class)
*
* @ApiResource(
*     collectionOperations={
*          "get",
*          "post"={"access_control"="is_granted('IS_AUTHENTICATED_ANONYMOUSLY')"},
*          "patch"
*     },
*     itemOperations={
*          "get",
*          "patch",
*          "put",
*          "delete"={"security"="is_granted('ROLE_ADMIN')"}
*     },
*     normalizationContext={"groups"={"journey:read"}},
*     denormalizationContext={"groups"={"journey:write"}},
*
*
* )
* @ApiFilter(SearchFilter::class, properties={"user","isFinished","treasureWay"})
*/
class CurrentJourney
{
/**
* @ORMId
* @ORMGeneratedValue
* @ORMColumn(type="integer")
* @Groups({"journey:read"})
*/
private $id;
/**
* @ORMColumn(type="integer", nullable=true)
* @Groups({"journey:read", "journey:write"})
*/
private $try;
/**
* //    * @ORMManyToOne(targetEntity=User::class, inversedBy="currentJourneys")
* @ORMManyToOne(targetEntity=User::class, inversedBy="waypoints")
*/
private $user;
/**
* //    * @ORMManyToOne(targetEntity=Waypoint::class, inversedBy="currentJourneys")
* @ORMManyToOne(targetEntity=Waypoint::class, inversedBy="users")
*/
private $waypoint;
/**
* @ORMColumn(type="integer",options={"default":"0"}) // integer: 0=abandonned ,1= in progress, 2= finished
* @Groups({"journey:read", "journey:write"})
*/
private $isFinished;
/**
* @ORMColumn(type="datetime")
*/
private $createdAt;
/**
* @ORMManyToOne(targetEntity=TreasureWay::class, inversedBy="currentJourneys")
*/
private $treasureWay;

我认为问题出在Content-Type上,请检查。应该是application/json,如果是其他东西,请更改

相关内容

最新更新