Advertisement
rafibatam

Difference between Query and Path

Oct 29th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. Difference between @Query and @Path on Retrofit2 Android :
  2.  
  3. // @Query
  4.  
  5. => Example API : https://jsonplaceholder.typicode.com/posts?userId=1&_sort=id&_order=desc
  6.  
  7.     @GET("posts")
  8.     Call<List<Post>> getPosts(
  9.             @Query("userId") Integer userId,
  10.             @Query("_sort") String sort,
  11.             @Query("_order") String order
  12.     );
  13.  
  14. // @Path
  15.  
  16. => Example API : https://jsonplaceholder.typicode.com/posts/2/comments
  17.  
  18.     @GET("post/{id}/comments")
  19.     Call<List<Comment>> getComments(@Path("id") int postId);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement