updateItem not working

Hi all,

We’re using the NPM library webflow-api webflow-api - npm, which is based on js-webflow-api, which is created and maintained by the Webflow team. GitHub - webflow/js-webflow-api: Node.js SDK for the Webflow Data API

We’re able to query the collection and add items but we’re not able to use the updateItem function.

Sample code:

const updatedItem = await webflow.collections.items.updateItem(process.env.WEBFLOW_COLLECTION_ID, itemId, updatedItemObject)

The error: An error occurred while updating item in Webflow collection JsonError: Missing required key "id"

However, note the second paramater itemId is being passed as expected. We confirmed the value is correct at that point.

Any tips would be much appreciated. Thanks much in advance.

The id goes into the object with fieldData. I don’t understand why there is an item_id and an id though… So I just have it the same and it works fine.

async function updateItem() {
  try {
    const collection_id_2 = "6722991e58b81ae2868d0092"
    const itemId = "67233e25770ba1539ef798b5";
    const id = itemId;

    const item = await webflow.collections.items.updateItem(collection_id_2, itemId, {
      id,
      fieldData: {
        name: "Testupdated",
        slug: "testupdated"
      },
    });

    return item;
  } catch (error) {
    console.error("An error occurred while updating the item:", error);
    return null;
  }
}