Components and dynamic zones do not return an id
In Strapi 5, components and dynamic zones do not return an id
with REST API requests so it's not possible to partially update them.
This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.
🔌 Is this breaking change affecting plugins? | Yes |
---|
Breaking change description
In Strapi v4
In Strapi v4, you can partially update a component by passing its component id
.
In Strapi 5
The response of components and dynamic zones in the REST API does not contain an id
, and partial updates on them is not possible.
Migration
This section regroups useful notes and procedures about the introduced breaking change.
Notes
In Strapi v4, you could do the following send requests that would return a component's
id
:// 1. GET /category/:id
category = fetch(...)
// 2. PUT /category/:id
{
data: {
name: 'category-name',
// Update component by its id
component: {
id: category.component.id // Use the id received in 1.
value: 'value'
}
}
}So you could specify the component
id
to update thevalue
field.In Strapi 5:
- The Draft & Publish feature has been reworked and documents can have both a draft and a published version.
- The default behaviour of the Content API is to return published data, for instance
PUT /category/:id
can be used to update the draft version of a document and publish it. - The REST API response returns the published version, so using the
id
would resort to trying to update the draft version of a component or dynamic zone with the unique identifier of its published version, which is not possible. - Trying to partially update a component will result in the following error:
Some of the provided components in component are not related to the entity
.
This breaking change only affects the REST API, not the Document Service API, because the Document Service API returns the draft version of a document by default. This also makes it possible to partially update a component or dynamic zone in the Content Manager.
Manual procedure
Update your custom code to send the full component to update when using the REST API.