Skip to content

Instantly share code, notes, and snippets.

@kdkanishka
Created April 19, 2019 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdkanishka/e8ddc725c4bb7c17cc77c8d9d5a82bba to your computer and use it in GitHub Desktop.
Save kdkanishka/e8ddc725c4bb7c17cc77c8d9d5a82bba to your computer and use it in GitHub Desktop.
/**
*
* @author kanishka
*/
public class RetrofitTest {
public static void main(String[] args) throws IOException {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://abc.com")
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient.build())
.build();
CategoryService categoryService = retrofit.create(CategoryService.class);
Call<Category> c = categoryService.list();
Response<Category> catR = c.execute();
if(catR.isSuccessful()){
System.out.println(catR.body().getId());
System.out.println(catR.body().getName());
System.out.println(catR.body().getTs());
}
}
}
interface CategoryService {
@GET("reception/5cb948d5e6ba7798c5973ab4")
Call<Category> list();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment