Hey there, I have an issue with the CMS API when updating an item of a collection.
Somehow the API will change the “slug”-field when updating some fields of an existing item but keeping the same slug.
So if:
GET https://api.webflow.com/collections/COLLECTION-ID/items
Returns an item with slug “abc” and an ITEM-ID.
[details=Example]
{
“items”: [
{
“_archived”: false,
“_draft”: false,
“name”: “test”,
“field-i-want-to-update”: “before”,
… some other fields … ,
“slug”: “abc”,
… Created, Modified and Published …,
“_cid”: “CID”,
“_id”: “ITEM-ID”
}
}[/details]
If I now want to update this item (or a field of this item) I have to make a
PUT https://api.webflow.com/collections/COLLECTION-ID/items/ITEM-ID
Where the “slug”-field is required. If i want to update some fields but keep the same slug “abc”:
[details=Example of Request Body]
{
“fields”: {
“_archived”: false,
“_draft”: false,
“name”: “test”,
“field-i-want-to-update”: “after”,
… some other fields … ,
“slug”: “abc”,
… Created, Modified and Published …,
“_cid”: “CID”,
“_id”: “ITEM-ID”
}
}[/details]
The Response show me an altered slug, with some random suffix added to it. Like “-2” or “-c”.
[details=PUT Response]
{
“_archived”: false,
“_draft”: false,
“name”: “test”,
“field-i-want-to-update”: “after”,
… some other fields … ,
“slug”: “abc-6”,
… Created, Modified and Published …,
“_cid”: “CID”,
“_id”: “ITEM-ID”
}[/details]
I could not figure out a way to keep the same slug other than making a DELETE Request to delete the complete Item and re-uploading it via POST. (That is not really an option as I loose the history and would double runtime - especially because of the 60/Min API limit).
I should mention that I rely on the slug, that is being generated from some of the fields, because I want to use it somewhere else where I can not make a HTTP Request to ask for the actual slug given by the CMS API.
I’d appreciate any help or explanation on why this has to be/stay this way and what alternatives I have.