Setting Custom Field Values
In Apicbase, you have the flexibility to create custom fields beyond the standard native options for Recipe, Menu, and Ingredient entities. You can access a list of these fields and their permitted values via the the Get Custom Field Definitions endpoint.
It's also possible to assign values to these custom fields when creating or editing Recipes, Ingredients, and Menus through their dedicated endpoints. The input attributes follow the same structure as the data object retrieved from their respective GET endpoints.
The custom_fields
field accepts a list of objects, each containing only two attributes: name
and value
. The name
attribute corresponds to the custom field's name, and it is case and capitalization-sensitive. The value
attribute represents the assigned value. For choice fields, this value is validated against the permissible choices. An input with an invalid value will result in a 400 BAD REQUEST
error response.
Here, we provide examples of potential values for the custom_fields
attribute, categorized by the type of custom field: text, single choice, or multi-choice
Text and Long Text
For text fields, simply provide the text as input:
{
"custom_fields": [
{
"name": "Menu Production Code",
"value": "STX-4068 (M)"
}
]
}
Single Choice
For single choice fields, provide the choice as input. This looks the same as a regular text field, but the input is validated against the allowed values.
{
"custom_fields": [
{
"name": "Production Counter",
"value": "4"
}
]
}
Multi Choice
For multi choice fields, provide the choice(s) as a list of values.
{
"custom_fields": [
{
"name": "Kitchen Utensils",
"value": ["Fork", "Knife"]
}
]
}
Setting multiple fields in the same request
It is possible to combine multiple custom fields in the same request, also fields of different types:
{
"custom_fields": [
{
"name": "Production Counter",
"value": "4"
},
{
"name": "Kitchen Utensils",
"value": ["Fork", "Knife"]
}
]
}
Custom fields not specified in a PATCH
request will retain their present values.
If you wish to explicitly remove the value of a custom field, it needs to be specified in the request with its value being either null
(for text and single choice fields) or an empty array (for multi choice fields).
Updated about 1 year ago