Search code examples
resthttpkotlinparse-platform

Fuel HTTP - Avoid URL encoding


Using retrofit I could make a get and avoid URL encoded like below:

@GET("classes/Tournaments")
    fun searchTournament(@Query(value = "where", encoded = false) query: String): Call<List<Tournament>>

In Fuel this GET request:

fun searchTournament(name: String): Any {
    val (request, _, result)
            = Fuel.get(baseUrl.plus("/classes/tournaments"), listOf("where" to mapOf("name" to name))).responseString()
    val (payload, error) = result

    println(request.url)

    return ""
}

generate this URL: https://parseapi.back4app.com/classes/tournaments?where=%7Bname%3DBrasileir%C3%A3o+2019%7D that causes an error.

I could not found anything clear in docs about avoids encoded. Is this possible?

My app is a Kotlin console App (Without Android)

When I send this Query to server it responds with an Http 500 - Internal Server Errors (without more details). I think it is not understanding the query.

2019-04-02T03:17:23.314Z - Uncaught internal server error.

The server is an instance of ParseServer(Back4App) I couldn't decode the query there.


Solution

  • Here is a clear instruction about using the rest api.

    https://docs.parseplatform.org/rest/guide/#query-constraints

    The value/formatting of where key is wrong. You must use double quotes and ':' instead of directly using the query key with '='.

    So your encoded URL should be something like this one: https://parseapi.back4app.com/classes/tournaments?where=%7B%22name%22%3A%22Brasileir%C3%A3o%2B2019%22%7D