I think this must be a bug because I don’t understand what I could be doing wrong. I have a few records that I want to fill a certain property, so I first look for the records and then use the id of each one to make an update. Here is the code:
async function main() {
const client = buildClient({ apiToken: X });
const recommenders = await client.items.list({filter: {type: 2635038}})
await recommenders
.filter((item) => item.variant === '')
.reduce(async (previousPromise, item) => {
try {
await previousPromise
await client.items.update(item.id, {variant: 'discreet'})
} catch (e) {
console.error(e)
}
}, Promise.resolve())
}
main();
This is an example of the response from one of the records:
{
"id": "205467339",
"type": "item",
"question": "203888330",
"variant": "",
"updated_at": "2023-10-03T13:10:01.417+01:00",
"created_at": "2023-10-03T13:10:01.413+01:00",
"item_type": {
"id": "2635038",
"type": "item_type"
},
"meta": {
"created_at": "2023-10-03T13:10:01.413+01:00",
"updated_at": "2023-10-03T13:10:01.417+01:00",
"published_at": "2023-10-03T13:38:17.074+01:00",
"publication_scheduled_at": null,
"unpublishing_scheduled_at": null,
"first_published_at": "2023-10-03T13:38:17.074+01:00",
"is_valid": false,
"is_current_version_valid": false,
"is_published_version_valid": false,
"status": "published",
"current_version": "356379725",
"stage": null
}
}
This is the error I receive:
Error: PUT https://site-api.datocms.com/items/205467339: 404 Not Found
[
{
"id": "302048",
"type": "api_error",
"attributes": {
"code": "NOT_FOUND",
"details": {}
}
}
]