Up - API Reference - Home
Requires JWT.
Update a record's user defined fields.
We don't update hierarchical or channel or ordering info for the record here.
If a field is localized, we only update the value for the language(s) provided in the request.
If we have linked records, we update all those records too.
We validate the fields before updating the record. We don't update fields that have a validation error (for class/classlist fields, that means we don't update the complete field is any subfield has an error). Validation.REPORT is allowed though.
Note: Even if all field updates yield validation errors, the request still succeeds. You'll have to inspect the validation report to see if any fields failed.
Note: when you change a field definition, all records using that field should be re-validated, and invalid fields should be reported. This means that the report can also hold refs to records with -invalid- data, because we don't throw data out.
You update the record by specifying the gid in record
and the updates in fields
. The optional language
and languages
parameter are only used for the returned data.
POST /api/p/<project gid>/records/update
Authorization: Bearer <JWT>
{
"record": "<record gid>",
"fields": {
"nl": {
"artnr": "CMS 225-945",
"name": "Caravell ijsconservator 174 liter",
"packing": 1,
"net_volume__l": 174,
"brand/key": "caravell"
}
}
}
record
the record's gid
.
fields
a dictionary holding the values for (some of) the fields, which can be keyed by either the field's name
or gid
. Such a dictionary is wrapped inside a dictionary holding the language. You can update multiple languages in one go. Note that for non-localized fields, if you specify that field value in more than one language, that fields' value must be the same for each language (for fields with values
options, that means the correct translation of the value). For fields with values
options, you can specify by value, but you can also update by key; to do so you must append /key
to the field's name
or gid
(like the brand/key
update for the brand
field).
language
return data for this (project) language.
languages
return data for these (project) languages.
If you request language
and/or languages
, you get the records' title
and fields
for the combined set. If you request neither, you'll get all available languages.
Authorization: <JWT>
{
"success": true,
"result": {
"record": "<record gid>",
"report.validation": [
{
"field": "28d7cbc3-ce07-45bd-8791-d21b2ae7b841",
"field_name": "artnr",
"language": "nl",
"result": "SUCCESS",
"keys": [],
"message_key": "",
"message_replacements": {}
},
…
]
},
"data": {
"records": {
"<record gid>": {
"gid": "<record gid>",
…,
"fields": {
"nl": {
"net_volume__l": 174,
"name": "Caravell ijsconservator 174 liter",
"packing": 1,
"artnr": "CMS 225-945",
"brand": "Caravell",
"brand/key": "caravell",
…
},
"en": {…}
}
}
}
}
}
record
the updated record.
report.validation
validation info for updated fields
When you update a record, the fields you send are validated against the field types and options, as specified by the record's definition. This is returned as a report.validation
in the result. Fields that failed validation ("ERROR") were not updated.
Each validation result has a number of fields:
field
the field's gid (only present for field validations)
field_name
the field's name (only present for field validations)
language
the language for the field's value (only present for field validations)
result
either SUCCESS
, REPORT
(warning), ERROR
, or NA
(not applicable)
keys
fixed values for errors, e.g. invalid_input
, min_items
, or restrict_to_values
message_key
a user-presentable message, with placeholders for replacements - these are between braces
message_replacements
replacement values for placeholders in the message_key
.
records
Record info with hierarchy, definition, field values. Unordered.
400
Bad request - missing parameters or wrong type or value
401
Unauthorized - missing or expired JWT
403
Forbidden - not a member of this project
422
Unprocessable entity - record doesn't exist