Item slug changes on update (PUT)

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.

1 Like

Hi @RFechtner, thanks for the report. This has been reported and is being looked at, as soon as there is an update, will let you know more info.

Thanks in advance!

Hi @cyberdave , thanks for the feedback!

I’m sorry, I couldn’t find a topic covering this issue…

Thank you for investigating!

Hi @RFechtner! You did great thanks! Will get back to you at the soonest!

Thanks for catching this, working on putting together a fix for it ASAP!

A fix has been deployed, let me know if you still are seeing this behavior!

Hi @nathan, just checked with Postman. Working like a charm!

Thank you all for the really fast patch, really appreciate it!

Hi - We are still seeing this type of behavior on our platform. Has the fix been deployed globally to everyone?

@nathan - Would you be able to assist please?

@cyberdave @nathan

Same issue here trying to update an existing item, using the very same slug as before:

{
    "msg": "Validation Failure",
    "code": 400,
    "name": "ValidationError",
    "path": "/collections/6091a5cdf769c6242914xxxx/items/64ad118dffe6a90955d7xxxx",
    "err": "ValidationError: Validation Failure",
    "problems": [
        "Field 'slug': Unique value is already in database: 'buy-house-in-hamburg-1234abcd'"
    ],
    "problem_data": [
        {
            "slug": "slug",
            "msg": "Unique value is already in database",
            "value": "'buy-house-in-hamburg-1234abcd'"
        }
    ],
    "extensions": {
        "input": {
            "collection_id": {},
            "item_id": {},
            "target": "live",
            "mode": "live",
            "need_staging": true,
            "need_live": true,
            "need_collections": false,
            "need_staging_draft": false,
            "isPatchMode": false,
            "isSilentMode": false,
            "skipInvalidFiles": false
        },
        "meta": {
            "authType": "oauth_user",
            "userId": {}
        }
    }
}

Ok, so I think I managed to get this one.

Create your item in draft with “_draft”=“true”. Don’t add a slug. Webflow will create a random one.

Then you can update your article and add the right slug, and set your article’s draft status to false.

From this point onwards any update to the article can be done while keeping the same slug.