Simplify fetching custom fields via API
Is your feature request related to a problem?
As a customer, suppose I have a feature with some custom fields, and I want to read the value of those custom fields from the API.
I can fetch the feature from the API and it does return the custom field values, but the field names are not returned:
curl https://api.flagsmith.com/api/v1/projects/16945/features/98737/ -H 'Authorization: Token ...'
{
"id": 98737,
"name": "greeting",
...,
"metadata": [
{
"id": 587,
"model_field": 192,
"field_value": "FOO-123"
}
]
}
Obtaining the name of this custom field requires two additional requests. First, obtain the field IDs based on the model_field IDs by calling GET /api/v1/organisations/15467/metadata-model-fields/:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 192,
"field": 252,
"content_type": 19,
"is_required_for": []
}
]
}
Then, using the returned field ID, get the custom field definitions by calling GET /api/v1/metadata/fields/?organisation=15467, which does return the field names and types:
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": 252,
"name": "JIRA ticket number",
"type": "str",
"description": "",
"organisation": 15467
}
]
}
Note that the last two requests also require pagination to be correctly implemented.
Describe the solution you'd like.
Return custom field names when fetching a feature via API. For example:
curl https://api.flagsmith.com/api/v1/projects/16945/features/98737/ -H 'Authorization: Token ...'
{
"id": 98737,
"name": "greeting",
...,
"metadata": [
{
"id": 587,
"model_field": 192,
"field_value": "FOO-123",
"field_name": "JIRA ticket number"
}
]
}
Describe alternatives you've considered
Provide an Admin API client that provides an abstraction to simplify this, which would be a sizeable maintenance effort.
Additional context
No response
Can I pick this up if ok? @matthewelwell
@existentialcoder yes, please go ahead. I'll assign it to you.