Mordag
Mordag

Reputation: 517

Retrofit 2 query parameter inside URL not used

Inside my Android App I'm trying to call the URL http://my-url.com/somestuff?type=type1. To create this call I am using retrofit 2.3.0. According to Android Studio the URL which is called is http://my-url.com/somestuff without the query which results in receiving a 404.

@GET("somestuff")
Call<MyDataModel> getStuff(
     @Query("type") String type
);

Upvotes: 0

Views: 248

Answers (1)

Mordag
Mordag

Reputation: 517

The issue was on my side. I implemented an interceptor which is rebuilding the url based on different states and I simplfy forgot to copy the old query to the new request builder.

for(int i = 0; i < original.url().querySize(); i++) {
    builder.addQueryParameter(original.url().queryParameterName(i), 
    original.url().queryParameterValue(i));
}

Upvotes: 1

Related Questions