[英]Symfony / api-platform PATCH NotEncodableValueException: “Syntax error”
我使用 api-platform,GET 和 POST 工作正常,我需要在我的實體中修補“isFinished”,但我有一個錯誤:REQUES Uncaught PHP Exception Symfony\Component\Serializer\Exception\NotEncodableValueException:“語法錯誤”
你認為我的實體有錯誤的配置嗎? 謝謝你的幫助。
/**
* @ApiResource()
* @ORM\Entity(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
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"journey:read"})
*/
private $id;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"journey:read", "journey:write"})
*/
private $try;
/**
* // * @ORM\ManyToOne(targetEntity=User::class, inversedBy="currentJourneys")
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="waypoints")
*/
private $user;
/**
* // * @ORM\ManyToOne(targetEntity=Waypoint::class, inversedBy="currentJourneys")
* @ORM\ManyToOne(targetEntity=Waypoint::class, inversedBy="users")
*/
private $waypoint;
/**
* @ORM\Column(type="integer",options={"default":"0"}) // integer: 0=abandonned ,1= in progress, 2= finished
* @Groups({"journey:read", "journey:write"})
*/
private $isFinished;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=TreasureWay::class, inversedBy="currentJourneys")
*/
private $treasureWay;
我認為問題出在您的Content-Type
上,請檢查一下。 如果是其他東西,應該是application/json
更改它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.