I am trying to sync data from another application to Kintone. I’m using the Kintone API and testing with cURL. I have data imported into Kintone already, and I am doing a full sync from our other data set to update the Kintone App.
How can I do an update similar to an SQL insert query that uses ‘on duplicate key update…’?
When I run this command (found in the “Update Records” API documentation) on a record that does not yet exist:
curl -X PUT "https://{subdomain}.kintone.com/k/v1/records.json" \
-H "Content-Type: application/json"
-H "X-Cybozu-Authorization: {authtoken}"
-d '{
"app": 2,
"records": [{
"updateKey": {
"field": "company_id",
"value": 20859
},
"record": {
"name": {
"value": "SBS"
},
"short_name": {
"value": "sbs"
},
"city": {
"value": "Colorado Springs"
},
"state": {
"value": "CO"
},
"zip": {
"value": ""
},
"phone": {
"value": "1234567890"
},
"website": {
"value": "https://www.testcompany.com"
},
"type": {
"value": "vendor"
}
}
}]
}'
I get this error:
{
"code": "GAIA_RE20",
"id": "...",
"message": "No records match the conditions specified in the \"updateKey\" field."
}
When I run the alternate command (found in the “Add Records” API documentation), on a record that exists, I get this error:
{
"code": "CB_VA01",
"id": "...",
"message": "Missing or invalid input.",
"errors": {
"records[0].company_id.value": {
"messages": ["This value already exists in another record."]
}
}
}
Is there a single command I can run for all records that either update (if it already exists) or adds new (if it does not already exist)?