Hi all,
We’re trying to add/update Webflow items in a collection. We’re able to connect and get details but updating seems to be working only intermittently at best (e.g., worked twice but haven’t able to see why or why not). We’ve confirmed that the key we’re using has the appropriate CMS write permissions.
This is a JavaScript stack the NPM SDK webflow-api
webflow-api - npm That SDK uses the js-webflow-api
GitHub - webflow/js-webflow-api: Node.js SDK for the Webflow Data API
We’re getting a JsonError: Missing required key "id"
error but the library function call createItemLive
we’re using doesn’t have an ‘id’ parameter.
The WEBFLOW_API_TOKEN is generated from Site Settings > Apps & Integrations > API Access. We confirmed that the token has CMS Write permissions.
Any tips would be much appreciated. Thanks much in advance!
const webflow = new WebflowClient({
accessToken: process.env.WEBFLOW_API_TOKEN,
})
// This works ok.
const collectionItems = await webflow.collections.items.listItemsLive(process.env.WEBFLOW_COLLECTION_ID)
console.info(`Webflow collection items:`, collectionItems)
// This doesn't work and returns an error of "An error occurred JsonError: Missing required key "id" at /var/task/node_modules/.pnpm/webflow-api@2.3.5/node_modules/webflow-api/core/schemas/builders/schema-utils/getSchemaUtils.js:32:19"
const newListing = {
isArchived: false,
isDraft: false,
fieldData: {
name: 'Foo Bar',
slug: 'foo-bar',
},
}
console.info(`Adding item to Webflow collection`, newListing)
const addedItem = await webflow.collections.items.createItemLive(process.env.WEBFLOW_COLLECTION_ID, newListing)