There is a specific order in which custom fields can be posted through API calls to files in Box. The following is an example using sample payload data that can be used as a reference when verifying the necessary API calls to make.
GET /folders/content
or utilize another API call to determine the file ID for an example file.GET /custom-fields/enterprise-templates
or
POST /custom-fields/templates
Note the template key{ "displayName": "Example Template", "fields": [ { "description": "Custom Field Example", "displayName": "CustomField", "hidden": false, "key": "custom1", "type": "string" } ], "hidden": false, "scope": "enterprise", "templateKey": "customTemplate" }
POST /files/{id}/custom-fields/{templateKey}/templates
{ "scope": "enterprise" }
Note: This will associate thecustomTemplate
template with the selected file.POST /files/{id}/custom-fields
{ "path": "/custom1", "scope": "enterprise", "template": "customTemplate", "value": "Custom Field Value" }
Note: this adds a custom field value to the template. The 'path' field in this POST must reference the fields.key from GET /custom-fields/enterprise-templates with a preceding forward slash.