Arif Nadeem
Arif Nadeem

Reputation: 8604

Retrofit 2 error URL query string must not have replace block

I am trying to call a legacy API using Retrofit 2, this is the URL "/api/0.3/v3/?endpoint=/admin/customers/6728382/addresses.json" and this is the interface method

@GET("/api/0.3/v3/?endpoint=/admin/customers/{customerId}/addresses.json")
Single<GetCustomerAddressesResponse> getUserAddresses(@Path("customerId") String customerId);

However I am getting this error,

"URL query string "endpoint=//admin/customers/{customerId}/addresses.json" must not have replace block. For dynamic query parameters use @Query."

How can I fix this?

Upvotes: 3

Views: 4072

Answers (2)

Ajay S
Ajay S

Reputation: 48602

"URL query string "endpoint=//admin/customers/{customerId}/addresses.json" must not have replace block. For dynamic query parameters use @Query."

As it suggests you should use @Query instead of @Path.

Single<GetCustomerAddressesResponse> getUserAddresses(@Query("customerId") String customerId);

You may like to read this in details about @Query annotation https://square.github.io/retrofit/2.x/retrofit/index.html?retrofit2/http/Query.html

Upvotes: 0

neo
neo

Reputation: 1404

I think id has to be int type. Try to change String to int.

Upvotes: 0

Related Questions