Blog

How to Encode SQL Search Queries in Backendless Console for Use by REST Clients

by on September 1, 2019

In another post, we explained how to run SQL searches against your mBaaS backend data. The SQL queries you run in Backendless Console can be used verbatim in your mobile and desktop applications built with Backendless whenever you need to run a search for the app data. We refer to the SQL queries supported by Backendless as the “where clause” since it must contain the WHERE part of an SQL statement.

When a REST client runs a data search, the SQL query is a parameter in the request URI. As a result, it must be a URL-encoded value. To make it easy for developers to get an encoded value, Backendless Console provides a way to encode SQL queries. For instance, using the Restaurant-to-Go app I’ve been using in this series, the following where clause runs a search for all restaurants with the name which includes the word “Cantina” and located in Frisco:

name LIKE '%cantina%' and locations.city = 'Frisco'

You can try running it against the Restaurant table to see the result:

Notice the URL Encode button right next to the SQL Search toggle. When you click the button, Backendless encodes the current SQL query so it can be used in a REST application:

Once the value is encoded, it can be copied/pasted into your app which uses Backendless REST API. Also, for your convenience, the URL Decode button reverses the encoding back.

For additional information see the documentation on how to use the Data Service API in a REST client.

Enjoy!

Leave a Reply