Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
I'm trying to use the REST API to get data. I've been able to get a filter to work on columns with no spaces in them, but I've not yet figured out the right syntax for using a column name containing spaces as part of a parameter.
I've tried %20, +, and _x0020_ as the space. I've tried wrapping the column name in parentheses, square brackets, single quotes, double quotes. I'm running out of things to try. Most commonly, I get an "unidentified token" error for the second word in my column name.
My call looks like:
...public/api/projects/PROJECT_NAME/datasets/DATASET_NAME/data?format=json&filter=Column+Name == 'abc'
Is it possible to use a column name which contains spaces in this way? Thank you in advance!
Hi @MossandRoy,
The issue here is that you need to use the strval or numval function when referencing a column name that contains spaces in a formula.
Example:
strval("Column Name") == "abc"
Here's an example cURL command that automatically encodes the query parameters:
curl --get --user 'API_KEY:' \
'http://DSS_HOST/public/api/projects/PROJECT_KEY/datasets/DATASET/data' \
--data-urlencode format='json' \
--data-urlencode filter='strval("Column Name") == "abc"'
Encoded URL:
/public/api/projects/PROJECT_KEY/datasets/DATASET/data?format=json&filter=strval%28%22Column+Name%22%29+%3d%3d+%22abc%22
Filters are written using the Formula language. You can read more about the available options here: Formula language.
Thanks,
Zach
Hi @MossandRoy,
The issue here is that you need to use the strval or numval function when referencing a column name that contains spaces in a formula.
Example:
strval("Column Name") == "abc"
Here's an example cURL command that automatically encodes the query parameters:
curl --get --user 'API_KEY:' \
'http://DSS_HOST/public/api/projects/PROJECT_KEY/datasets/DATASET/data' \
--data-urlencode format='json' \
--data-urlencode filter='strval("Column Name") == "abc"'
Encoded URL:
/public/api/projects/PROJECT_KEY/datasets/DATASET/data?format=json&filter=strval%28%22Column+Name%22%29+%3d%3d+%22abc%22
Filters are written using the Formula language. You can read more about the available options here: Formula language.
Thanks,
Zach