Create Metadata Collection
/documents/api/1.2/metadata/{collectionName}
Create a named collection to store field values as strings. To create a global collection, you must log in as an administrator. A global collection can be used by all tenant users.
Before you can assign field values, you must assign the collection to a folder or file.
New:
User personal collections can be created by prefixing the collection name with Personal.. A personal collection will be visible and accessible only to the user who created it; therefore, no naming conflict will exist if two different users define their own personal collections using the same name.
Note:
Global collection names must be unique in the instance where the collection is defined, and you cannot change the collection name after it is created. For these reasons, consider implementing naming conventions if you plan to make extensive use of metadata collections.
Request
- application/json
- application/xml
-
collectionName: string
Maximum Length:
240Global collection names must be unique in the instance where the collection is defined and used. User personal collection names must start with
Personal., such asPersonal.MyCollection, to be user scoped.Note:
You cannot change the name of a collection after you create it.
The following restrictions apply to collection and field names:
- Collection and field names can't start or end with a space.
- The combined length of the collection and field name can't exceed 240 characters.
- Collection and file names aren't case-sensitive; that is,
Field Nameandfield nameare considered identical.
Don't use the following characters in collection or field names:
/ \ < > [ ] { } = $ % ' * " ? : # & ^ . , | The following strings are also not allowed in collection or field names:
- NUL
- NULL
- xSystem
- xUser
- xAF
- dMetadataUnitID
- dParentMetadataUnitID
- dMetadataInheritLevel
- dAssignedMetaCollection
- dMetaCollection
- dMetaCollections
- dMetadataCollectionID
- dMetadataID
objectDescription of fields available to create a metadata collection.
-
fields:
string
Maximum Length:
240One or more field names separated by commas. You can add and remove fields after the collection is created. Field names must be unique within the collection. All fields will be of type
text.The following restrictions apply to collection and field names:
- Collection and field names can't start or end with a space.
- The combined length of the collection and field name can't exceed 240 characters.
- Collection and field names aren't case-sensitive; that is,
Field Nameandfield nameare considered identical.
Don't use the following characters in collection or field names:
/ \ < > [ ] { } = $ % ' * " ? : # & ^ . , | The following strings are also not allowed in collection or field names:
- NUL
- NULL
- xSystem
- xUser
- xAF
- dMetadataUnitID
- dParentMetadataUnitID
- dMetadataInheritLevel
- dAssignedMetaCollection
- dMetaCollection
- dMetaCollections
- dMetadataCollectionID
- dMetadataID
-
fieldsArray(optional):
array fieldsArray
Can be used instead of
fieldsparameter if more granular control over created fields is desired. If bothfieldsandfieldsArrayare supplied, then the former will be ignored.
arrayfields parameter if more granular control over created fields is desired. If both fields and fieldsArray are supplied, then the former will be ignored.object-
defaultValue(optional):
string
Default value of the field. If the
fieldTypeisdate, the value should be in theyyyy-mm-ddThh:mm:ssform. Forbooleantypes, valid values should be (1) fortrueand (0) forfalse. -
fieldDescription(optional):
string
Description of the field.
-
fieldName(optional):
string
Field names as described for
fieldsinput parameter. -
fieldType(optional):
string
Type of the field.
Possible values are:
- text (default)
- number
- date
- boolean
{
"fields":"FieldA,FieldB"
}
Response
- application/json
- application/xml
201 Response
The request was fulfilled.
objectDescription of fields available in the create metadata collection response.
-
errorCode(optional):
number
An error code of zero (0) indicates no errors.
400 Response
Request parameters are not formatted correctly.
A collection with that name already exists.
Examples
The following example creates a collection called CollectionA with two fields, A1 and A2.
POST .../metadata/CollectionA
Request Header
None.
Request Body
{
"fields": "A1,A2"
}
HTTP Status Code
HTTP_STATUS = 200
JSON Response
{
"errorCode": "0"
}
Example 2
The following example creates a personal collection called Personal.CollectionA with multiple fields of different types with descriptions and default values.
POST .../metadata/Personal.CollectionA
Request Header
None.
Request Body
{
"fieldsArray":[
{"fieldName":"FieldA", "fieldType":"text", "fieldDescription":"Field A", "defaultValue":"Hello world"},
{"fieldName":"FieldB", "fieldType":"number", "fieldDescription":"Field B", "defaultValue":123},
{"fieldName":"FieldC", "fieldType":"date", "fieldDescription":"Field C", "defaultValue":"2020-02-20T11:12:13"},
{"fieldName":"FieldD", "fieldType":"boolean", "fieldDescription":"Field D", "defaultValue":1}
]
}
HTTP Status
HTTP_STATUS = 200
JSON Response
{
"errorCode": "0"
}
Example 3
The following example attempts to create a collection using an already existing name.
POST .../metadata/CollectionA
Request Header
None.
Request Body
{
"fields": "field1,field2"
}
HTTP Status
HTTP_STATUS = 409
JSON Response
{
"errorCode": "-17",
"errorKey": "!csUnableToCreateMetaColDef!csMetaDefinitionExists,CollectionA",
"errorMessage": "Unable to create metadata collection definition. Metadata field definition 'CollectionA' is already defined.",
"title": "Unable to create metadata collection definition. Metadata field definition 'CollectionA' is already defined.",
"type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}
Example 4
The following example attempts to create a collection using an invalid character in the name.
POST .../metadata/CollectionA,B
Request Header
None.
Request Body
{
"fields": "field1,field2"
}
HTTP Status Code
HTTP_STATUS = 400
JSON Response
{
"errorCode": "-96",
"errorKey": "!csCollectionNameInvalidCharacters,CollectionA\\,B",
"errorMessage": "Invalid characters in the collection name 'CollectionA,B'.",
"title": "Invalid characters in the collection name 'CollectionA,B'.",
"type": "https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}