Jono
Jono

Reputation: 18128

How to append api url to Base URL in retrofit?

Hi i am trying to append url to include an id to the end of it.

below is what i have written

@DELETE("/customer-management/id/{id}")
    fun deletUser(@Path("id") id: String): Single<Response<ResponseBody>>

This doesnt work and instead tries to make a request to this url:

http://localhost/customer-manegement/id/%2Fcustomer-management%2id%2F9a4615d5-aaa9-4a56-ff43-fb4ef7a54f96",

It should be

http://localhost/customer-manegement/id/2F9a4615d5-aaa9-4a56-ff43-fb4ef7a54f96

The docs from retrofits Path indicates it should work as i expected:

Simple example:

* 
 * GET("/image/{id}")
 * Call ;ResponseBody; example(@Path("id") int id);
 *
 * Calling with {@code foo.example(1)} yields {@code /image/1}.

Upvotes: 2

Views: 1918

Answers (1)

Alexander Perfilyev
Alexander Perfilyev

Reputation: 6829

http://localhost/customer-manegement/id/%2Fcustomer-management%2id%2F9a4615d5-aaa9-4a56-ff43-fb4ef7a54f96"

It seems that your base url is http://localhost/customer-manegement/id/ So your request should look like

@DELETE("/{id}")
fun deletUser(@Path("id") id: String): Single<Response<ResponseBody>>

Upvotes: 1

Related Questions