You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following rules apply when denormalizing embedded relations:
If an @id key is present in the embedded resource, then the object corresponding to the given URI will be retrieved through the state provider. Any changes in the embedded relation will also be applied to that object.
If no @id key exists, a new object will be created containing state provided in the embedded JSON document.
When setting allow_extra_attributes: false this results in Extra attributes are not allowed ("@id" is unknown).
If using json and not ld+json and sending id instead you get the same error on id.
P.S. not sure if intentional but for the update to actually work even if extra attributes allowed @id needs to also be provided on the parent entity.
Possible Solution
Allow @id (or maybe also @type@context) with allow_extra_attributes: false and ld+json.
Allow id with allow_extra_attributes: false and json.
Alternatively for more flexible solution, in the Entry ApiProperty or somewhere else add and option to set the base $allowedAttributes with default values here:
Description
As mentioned in documentation https://api-platform.com/docs/core/serialization/#denormalization
When setting
allow_extra_attributes: false
this results inExtra attributes are not allowed ("@id" is unknown).
If using json and not ld+json and sending
id
instead you get the same error onid
.P.S. not sure if intentional but for the update to actually work even if extra attributes allowed
@id
needs to also be provided on the parent entity.How to reproduce
Test example https://github.com/ili101/api-platform/blob/subTest/Test.ps1 (uncomment
allow_extra_attributes
in api_platform.yaml)Possible Solution
Allow
@id
(or maybe also@type
@context
) withallow_extra_attributes: false
and ld+json.Allow
id
withallow_extra_attributes: false
and json.Alternatively for more flexible solution, in the Entry ApiProperty or somewhere else add and option to set the base
$allowedAttributes
with default values here:core/src/Serializer/AbstractItemNormalizer.php
Line 423 in 5523bf5
Something like:
Additional Context
api-platform/api-platform#2096
api-platform/api-platform#2620
https://stackoverflow.com/questions/70379382/how-to-update-nested-entity-with-api-platform
The text was updated successfully, but these errors were encountered: