Unicat API Reference

Up - API Reference - Home


/api/p/<project gid>/definitions/metadata/set

Requires JWT

Add or update a metadata field for a definition.

The name should always have at least one dot (.), for grouping.

Request

POST /api/p/<project gid>/definitions/metadata/set
Authorization: Bearer <JWT>

{
    "definition": "<definition gid>",
    "name": "group.code",
    "type": "textline",
    "is_localized": false,
    "value": "EC1232100921",
}

definition gid of the definition to add the metadata field to
name name for the metadata field - must look like a variable name, using only upper/lowercase letters, digits, dots, and underscores, and cannot start with a digit - must contain at least one dot, doesn't start or end with a dot, and no successive dots

optional

type the metadata fields' type, see metadata
is_localized is the metadata field value different for different languages
value the metadata fields' value

If localization is set, the value should be a dictionary with all language codes as keys, e.g. {"en": "Chapter", "nl": "Hoofdstuk"}

If the value doesn't match the type, the value will be coerced to the type on a best-effort basis.

Success response

Authorization: <JWT>

{
    "success": true,
    "result": {
        "definition": "<definition gid>"
    },
    "data": {
        "definitions": {
            "<definition gid>": {}
        },
        "layouts": {
            
        }
    }
}

result

definition the definition with the added metadata field - this is a working copy.

data

definitions Definition info with name, classes, fields, metadata.
layouts Layout info with hierarchy, if the layout changed to a working copy.

Error responses

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 - can't work with this item