Unicat API Reference

Up - API Reference - Home


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

Requires JWT

Add or update a metadata field for a field.

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

Request

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

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

field gid of the field 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": "w [mm]", "nl": "b [mm]"}

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": {
        "field": "<field gid>"
    },
    "data": {
        "fields": {
            "<field gid>": {}
        }
    }
}

result

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

data

fields Field info with name, type, options, metadata.

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