`INVALID_FORMAT` / 'id is not a permitted key' error on `item.publish()` with `datocms-client` (edited title)

Hey there @corey.gwin, and welcome to the forums! I believe we just answered same question over email sent by a colleague of yours? But to reiterate:

This is unfortunately a known bug with the old client.

datocms-client has actually been deprecated for a couple years now: datocms-client - npm

It’s replaced by the newer @datocms/cma-client-node, which has similar methods, but not 100% the same syntax (meaning there will likely be some porting work and testing involved, unfortunately): @datocms/cma-client-node - npm

In the meantime, if this is the only issue you’re running into with the old client, there is a workaround that might help. You can add {serializeRequest: false} as the third parameter for item.publish(), like this:

await client.item.publish(
    "165017661", // record ID
    {}, // body
    {}, // query string
    { serializeRequest: false } // this is the actual workaround
  );

Unfortunately, we don’t have the resources to keep updating the deprecated old client, so I’m not sure how long that workaround will be effective for (or what else might break), but hopefully that could work for you for now?

Two other workarounds, if that doesn’t work:

  • You can use the Bulk Publish method to publish just that one item, if you don’t need to specify a particular locale (i.e. you’re ok with publishing the entire record at once, including all its locales)
  • You can also run the new client with the old side by side (like per file, or per call) and gradually upgrade specific pages/methods as needed. This will slightly increase your bundle size, but would allow you to gradually upgrade to the newer client instead of doing the whole project at once.

Hope that helps! Please let me know if I can clarify anything further.

1 Like