@Documented
@Retention(value=RUNTIME)
@Target(value=PARAMETER)
public @interface Path
Retrofit.stringConverter(Type, Annotation[])
(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%25Doe
whereas foo.notEncoded("John%Doe")
yields /user/John%Doe
.
Path parameters may not be null
.
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
value |
Modifier and Type | Optional Element and Description |
---|---|
boolean |
encoded
Specifies whether the argument value to the annotated method parameter is already URL encoded.
|