I use api-platform, GET and POST works fine, I need to patch isFinished
in my entity but I get an error:
REQUEST Uncaught PHP Exception
Symfony\Component\Serializer\Exception\NotEncodableValueException: "Syntax error"
Do you think my entity have bad configuration?
Thank you for help.
/**
* @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=abandoned ,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;
I think the problem is about your Content-Type
, check it.
It should be application/json
change it if it was somethings else