Using optionalFields in queries
Overview
By default, some endpoints do not return every field upon resource request.
Retrieve these additional fields by specifying them in the optionalFields query parameter.
This guide demonstrates how to request optional fields using the Get All Feature Flags endpoint as an example.
Requesting optionalFields
Example 1: Query without optionalFields
Request
curl -L -X GET 'https://api.kameleoon.com/feature-flags' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
Response
[
{
"id": 395,
"featureKey": "plp___4_products_per_row",
"name": "PLP : 4 products per row",
"description": "",
"tags": [],
...
},
...
]
Notice that the tags field is empty.
Optional fields return empty values unless they are explicitly requested.
Example 2: Query including the tags field
Request
note
Request multiple optional fields by separating them with commas in the optionalFields parameter.
For example, use optionalFields=tags,description.
curl -L -X GET 'https://api.kameleoon.com/feature-flags?optionalFields=tags' \
-H 'Content-Type: application/json' \
-H 'Accept: */*' \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
Response
[
{
"id": 395,
"featureKey": "plp___4_products_per_row",
"name": "PLP : 4 products per row",
"description": "",
"tags": [
"product page"
],
...
},
...
]