Deleting CMS items with API results in error

I’m using the api to offload CMS items to an external database. The flow is like this:

  1. I create a new CMS item (blog post).
  2. The earliest CMS item in my blog collection gets dumped to my external database (thus freeing up space). This works perfectly.
  3. The earliest CMS item is deleted.

That’s the plan at least. However, it won’t let me delete anything that has a connection to any other CMS items. Since I have a blog, all items are cross connected in tons of places.

This renders the API delete function completely useless, as it doesn’t seem to have any “unbind” function at all, and surely I can’t be expected to go in and manually disconnect all links? Is this how it’s supposed to work?

No idea what to do here.

I’m planning on having 1000s of blog posts that uses the incredible features of the Webflow CMS and make them intertvined with eachother (with stuff like “other articles like this”, “other articles with similar tags” etc), but if that means I’ll never ever be able to delete posts…

I’m going to hit the CMS limit sooner or later and have to migrate away. Is there really no way to unbind a CMS item other than visiting each and every item manually?

Hello,

This is a great question, thank you for reaching out.

In a way, this isn’t possible within the setup of the CMS API.

Would it be possible to experiment with an alternative workaround where there is a GET to all the items, then see which items have references to the item that need to be deleted, delete those references, and then finally delete the item?

Let me know if this works, and we can maybe figure out something from there if necessary.

Hey there Riley, thanks for answering!

Hmm, that might work! How would the query to get items with a custom field like the “similar articles” field I have in the item look, though?

Any ideas here? I’m afraid I’m a bit of a novice in this, so any help is appreciated :slight_smile:

Great question!

Depending on the type of field you’re using, you can target the specific fields used in the CMS with these field type names used in the API

To where you can get all the items using GET /collections/:collection_id and then find the ones using the specific field type for the similar articles.

Let me know if this helps.

The API has a 100 item limit though, so I can’t sort after the fact?

Is there a way to

GET /collections/collection_id/item/custom_field/custom_field_id

?

Anything you can do to help here, @RileyJones ?

Hello.

To sort through the 100 item limit, the offset parameter can be utilized to cycle through the next list of 100 items.

So in order for the item that is being referenced from another item to be deleted, the item that is referencing the soon to be deleted item will need to be updated to where the similar articles field is not using that referenced item we want to delete.

Once the item is updated, then the process of deleting an item can be done.

I have made a quick video in order to showcase an example.

Let me know if you have further questions.

Hey Riley!
Thanks so much for taking the time to make a video. I’m still not 100% sure how I’m going to do this, as I have to cycle through 5000 articles every time etc., and there’s an additional step as one item can reference many, so I can’t just blank out the reference fields. But you’ve put me on the right track :slight_smile:

Still think it would be much easier if Webflow just let us force delete stuff though. I don’t see why not. (also, it’s a bit against the whole #nocode thing I’d argue)

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.