Created
April 19, 2019 04:33
-
-
Save kdkanishka/e8ddc725c4bb7c17cc77c8d9d5a82bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @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