webflow / js-webflow-api

Node.js SDK for the Webflow Data API
https://www.npmjs.com/package/webflow-api
286 stars 93 forks source link

API returning different name for fields #93

Open jamesvclements opened 1 year ago

jamesvclements commented 1 year ago

My collection has a field named Summary: Webflow - Lux Capital-Wednesday-May-24-2023-02 53 03PM@2x

The API is returning the field as 'description-3': GET newsletter item - My Workspace-Wednesday-May-24-2023-02 54 33PM@2x

summary isn't found in GET or PATCH or POST calls. Is this the best repo to submit bugs to the Webflow API as a whole?

Jeandcc commented 1 year ago

This is not a bug. That field name on the API is set when you create the field, and never changes, even if you change it through the Webflow CMS. Once the field was created with the name X, it will always have that name.

Also, if you delete a field and create a new one with the same name, the new field will not be able to have the original name, say "summary". Webflow will always increment a number to the end of the field name so field names never repeat in the back-end.

What you can do to improve the work on your end is to create a helper function that gets the field slug from the field name. For that you will need to fetch the collection schema from the CMS API.

ReflextionsDev commented 9 months ago

Is there any way to deeply delete a field so that the field name is available again? It's especially inconvenient to work with dashes as object field names and makes types dirty with arbitrary numbers...