retrofit / retrofit2.http / Path / <init>

<init>

Path(value: String, encoded: Boolean)

Named replacement in a URL path segment. Values are converted to strings using (or Object#toString(), if no matching string converter is installed) and then URL encoded.

Simple example:


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

Values are URL encoded by default. Disable with encoded=true.


  @GET("/user/{name}")
  Call<ResponseBody> encoded(@Path("name") String name);
 
  @GET("/user/{name}")
  Call<ResponseBody> notEncoded(@Path(value="name", encoded=true) String name);
  
Calling foo.encoded("John+Doe") yields /user/John%2BDoe whereas foo.notEncoded("John+Doe") yields /user/John+Doe.

Path parameters may not be null.