Updating repeatable components with the Document Service API is not recommended
In Strapi 5, it's not recommended to update repeatable components with the API, due to some limitations of the new Document Service API.
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.
Breaking change description
In Strapi v4
You could update a repeatable component with its id
.
In Strapi 5
Strapi 5 uses documentId
due to the introduction of the Document Service API, and you can't update a repeatable component by its documentId
due to the way the Draft & Publish feature works with the new API.
Migration
Notes
In Strapi 5, draft components and published components have different ids, and you could fetch data like follows:
// Request
GET /articles // -> returns published article
// Response
{
documentId …
component: [
{ id: 2, name: 'component-1' },
{ id: 4, name: 'component-2' },
]
}
You can then try to do the following:
PUT /articles/{documentId} // <== Update draft article
{
documentId …
component: [
{ id: 2, name: 'component-1-updated' }, // <== Update component 1
]
}
However, this would fail because the component id of the draft article is different from the published one. Therefore, it's not recommended to try to update repeatable components with the Document Service API.