Skip to main content

createField

MetadataFieldWrapper createField(templateId, MetadataFieldRequest)

POST /api/2.0/files/metadata/templates/{templateId}/fields

Add a metadata field

Adds a field to an existing metadata template. Only a DocSpace admin can change templates. The field name must be unique within the template regardless of case and at most 255 characters, the type must be one of the published ones, a choice field needs at least one option and unique option values, a field of another type takes no options. A field without order is placed after the last field of the template. The entries the template is already assigned to get the field without a value: nothing is written on them and no cascade runs. The answer is the created field with its generated option identifiers. A template that does not exist is answered with 404, an invalid field with 400.

Parameters​

NameInTypeDescriptionNotes
templateIdpathInteger (int32)The template ID.[required] [example: 1]
MetadataFieldRequestbodyMetadataFieldRequestThe parameters of the field.[required]

Responses​

Status codeDescriptionTypeResponse headers
200New metadata fieldMetadataFieldWrapperX-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
400Invalid field: an empty, repeated or too long name, an unknown type, options on a non-choice field or a choice field without options--
403You don't have enough permission to perform the operation--
404Template not found--
401UnauthorizedErrorApiResponse-
429Too Many Requests.ErrorApiResponseRetry-After
500Internal Server Error.ErrorApiResponse-
502Bad Gateway. Returned by the reverse proxy, response body may be HTML and not JSON.--
503Service Unavailable. Returned by the reverse proxy, response body may be HTML and not JSON.--

Return type​

MetadataFieldWrapper

Authorization​

Basic, OAuth2 (scopes: read, write), ApiKeyBearer, asc_auth_key, Bearer, OpenId

HTTP request headers​

  • Content-Type: application/json
  • Accept: application/json