Using optionalFields
in Queries
Overview
Some endpoints don’t return every field by default when you request a resource.
You can 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 Optional Fields
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
You can request multiple optional fields by separating them with commas in the optionalFields
parameter.
For example: 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"
],
...
},
...
]