The API I'm using (iTop) allows a get request to have a JSON body, and an OQL statement within the JSON in the form:
json_data= {
...,
"key": "SELECT Animal",
...
}
I have been using %
, the wildcard character in iTop's OQL, like so:
json_data= {
...,
"key": "SELECT Animal WHERE name LIKE '%ant%'",
...
}
(which would return animals such as "ant", "manta ray", and "anteater")
Problems arise when I have a repeated character right after the %
symbol:
json_data= {
...,
"key": "SELECT Animal WHERE name LIKE '%aardvark%'",
...
}
The API responds with:
Error: Parameter json_data is not a valid JSON structure
I have noticed this behavior with other characters, but not all (%bb, %cc, etc. break the structure, but %hh, and %zz do not).
Is this a problem with the way the API parses the JSON, or is there something I am doing wrong? Is %aa
a possible escape character, or some type of regex syntax? I have not found any relevant information in the API documentation.
with help from the sourceforge forums, the solution is to replace the '%' with a unicode % ('\u0025').
SELECT Animal WHERE name LIKE '\u0025aardvark\u0025'
This is likely a bug in iTop...