1

Trying to implement a custom solution for interacting with TestRail API(http://docs.gurock.com/testrail-api2/accessing), I'm kind of stuck in the following situation:

Api calls are made like this: /index.php?/api/v2/get_case/1, meaning that after anything "?" is a query string param. Is there a way to parametrize this with Retrofit?

If I do something like this:

@GET("index.php?/api/v2/get_case/{id}")
Call<TestCase> getTestCase(@Query("id") int id);

I get this exception:

java.lang.IllegalArgumentException: URL query string "/api/v2/get_case/{id}" must not have replace block. For dynamic query parameters use @Query.

Got that...but how can I proceed further using Retrofit?

mbob
  • 590
  • 1
  • 4
  • 22

1 Answers1

0

Solved this through interceptor

Request currentRequest = chain.request();
String finalURL = currentRequest.url().toString().replace("index.php/", "index.php?/");

Request.Builder request = currentRequest.newBuilder()
        .addHeader("Authorization", authToken)
        .addHeader("Content-Type", ContentType.JSON.toString())
        .url(finalURL);
mbob
  • 590
  • 1
  • 4
  • 22