I want to filter a field of type mediumtext for the equal sign. But that throws a 400 Bad Request error. I get the same result when I filter for the greater-than or smaller-than sign. I guess because these symbols conflict with the SQL comparison operators.
I am making a request to MySQL Maria database via the dreamfactory’s API.
I tried escaping the equal sign with a backslash, but it did not work.
What can I do now?
Details:
Request URL: …/mytablename?fields=content&filter=content%20like%20%25%3D%25
Response Body:
{
“error”: {
“code”: 400,
“context”: null,
“message”: “Invalid or unparsable field in filter request: ‘content like %’”,
“status_code”: 400
}
}
It’s a old post, but to users having same problem can be a solution:
In SQL to use the LIKE you must use this format:
content like “%my search%”
(return all record with the words: my search)
The Cocomo request url Request URL: …/mytablename?fields=content&filter=content%20like%20%25%3D%25
is the same as: Request URL: …/mytablename?fields=content&filter=content like %=%
The problem, Dreamfactory have a limitation/bug in SQL query function:
The sign: = , cannot be used in the LIKE instructions, and get the message error;
I think because of conversion (encode/decode) to JSON the url string gets scrambled!
`----------------------------------------------------------------------------------------------------------------
One recommendation is to use the filter like this: Request URL: …/mytablename?fields=content&filter=(content%20like%20%22%25my%20search%25%22)
Other solution to validate filters is using the “API DOCS” menu option in DreamFactory dashboard, go to the database service, select the:
GET /mydatabase/_table/{table_name} api endpoint
In there you have the field filter, where you put your query: (content like "%my search%")
and when make the call (button “Try it out!”), dreamfactory show the Request Url endpoint formatted, then copy and past in your code.