

A corresponding parameter must be annotated with using the same string. A replacement block is an alphanumeric string surrounded by.

URL ManipulationĪ request URL can be updated dynamically using replacement blocks and parameters on the method. can also specify query parameters in the URL. The relative URL of the resource is specified in the annotation. There are eight built-in annotations: HTTP, GET, POST, PUT, PATCH, DELETE, OPTIONS and HEAD. Request MethodĮvery method must have an HTTP annotation that provides the request method and relative URL. Object conversion to request body (e.g., JSON, protocol buffers)Īnnotations on the interface methods and its parameters indicate how a request will be handled.URL parameter replacement and query parameter support.Use annotations to describe the HTTP request: Call> repos = service.listRepos("octocat")

GitHubService service = retrofit.create(GitHubService.class) Įach Call from the created GitHubService can make a synchronous or asynchronous HTTP request to the remote webserver. Retrofit retrofit = new Retrofit.Builder() The Retrofit class generates an implementation of the GitHubService interface. public interface GitHubService String user) Retrofit turns your HTTP API into a Java interface.
