Hi
I have written some code that checks for duplicates in a database and then updates duplicates with some data. I can find the duplicates no problem, but updating individually would be slow, so I wanted to use your “Batch” update.
The code example looks like this (API Key removed):
curl -X POST \
'https://bika.ai/api/openapi/bika/v1/spaces/spcFpUlo67cfVDxGnuOXg6km/resources/databases/datNXkyEKqOGd1nTtdjvXjwR/records/batch' \
-H 'Authorization: Bearer XXX' \
-H 'Content-Type: application/json' \
-d '{
"records": [
{
"recordId": "recm1yt41tERDAFIc3AEfVPw",
"cells": [
{
"fieldId": "fld23UNMuPnahQpXt1Ox1YW2",
"value": 1
}
]
},
{
"recordId": "recQUtjEDu8VpEHaTUedH1Ax",
"cells": [
{
"fieldId": "fld23UNMuPnahQpXt1Ox1YW2",
"value": 2
}
]
},
{
"recordId": "recoKMgv6pcCmf0GUGjdwjAi",
"cells": [
{
"fieldId": "fld23UNMuPnahQpXt1Ox1YW2",
"value": 3
}
]
},
{
"recordId": "recenKFVah14xvU7Uu6X4iuC",
"cells": [
{
"fieldId": "fld23UNMuPnahQpXt1Ox1YW2",
"value": 4
}
]
},
{
"recordId": "recZLY0ouL9XiudPv2PWVvYd",
"cells": [
{
"fieldId": "fld23UNMuPnahQpXt1Ox1YW2",
"value": 5
}
]
},
{
"recordId": "recmrs7vwmWGd1rrAGDoamRo",
"cells": [
{
"fieldId": "fld23UNMuPnahQpXt1Ox1YW2",
"value": 1
}
]
},
{
"recordId": "recDaVBfByUteiagevJqqpZy",
"cells": [
{
"fieldId": "fld23UNMuPnahQpXt1Ox1YW2",
"value": 2
}
]
},
{
"recordId": "recbHtObCRvhGglR10UT8amc",
"cells": [
{
"fieldId": "fld23UNMuPnahQpXt1Ox1YW2",
"value": 3
}
]
}
]
}'
For some reason I can get individual records to update, but when I use Batch Update (from Bika OpenAPI Reference | Bika.ai) I cannot get it to work. I constantly get a response with a ZodError like below.
Updating batch 1/1, 8 records...
Failed to update batch 1:
Bika.ai API Error Details: {
"success": false,
"error": {
"issues": [
{
"code": "invalid_type",
"expected": "array",
"received": "undefined",
"path": [
"cells"
],
"message": "Required"
}
],
"name": "ZodError"
}
}
Can you help with trying to get this to work, am iI misinterpreting your API docs?
I am using your OpenAPI documentation, which states that cells
should be an array of objects with fieldId
and value
, and my request payload matches this exactly.
Why is the API is reporting cells
as undefined
when it’s clearly present and correctly formatted in the request.
Many thanks in advance