I'm trying to implement the TheMovieDB API using Retrofit and I'm having trouble appending the api key to the beginning of the query. It feels like TheMovieDB is at fault here for having an untraditional way of asking for the api key at the start of the query.
When trying to intercept the request and adding the query parameter, like so, it gets appended to the end of the request, which is not what I want.
private class WebApiAuthenticator implements RequestInterceptor {
@Override
public void intercept(RequestFacade request) {
if (apiKey != null) {
request.addEncodedQueryParam(PARAM_API_KEY, apiKey);
}
}
}
And the service implementation:
@GET("/search/multi&query={query}")
void getSearchResults(@Path("query") String query, Callback<String> callback);
This produces this result:
---> HTTP GET https://api.themoviedb.org/3/search/multi&query=mysearchquery?api_key=thisismyapikey
I want this result:
---> HTTP GET https://api.themoviedb.org/3/search/multi?api_key=thisismyapikey&query=mysearchquery
How do I go about adding my query parameter to the start of the request instead?