retrofit path vs query
2020. 9. 26. 15:59ㆍ모바일/Android_Java
1
Consider this is the url:
www.app.net/api/searchtypes/862189/filters?Type=6&SearchText=School
Now this is the call:
@GET("/api/searchtypes/{Id}/filters")
Call<FilterResponse> getFilterList(
@Path("Id") long customerId,
@Query("Type") String responseType,
@Query("SearchText") String searchText
);
So we have:
www.app.net/api/searchtypes/{Path}/filters?Type={Query}&SearchText={Query}
Things that come after the ? are usually queries.
2
@GET("/user/{username}?type={admin}")
Here username
is the path
variable, and type
is the query variable
@GET("/user/{username}?type={admin}")
void getUserOuth(@Path("username") String username, @Query("type") String type)
3
@Query
- This annotation represents any query key value pair to be sent along with the network request
@Path
- This annotation implies that the passed parameter will be swapped in the endpoint path
출처 : stackoverflow.com/questions/37698501/retrofit-2-path-vs-query
'모바일 > Android_Java' 카테고리의 다른 글
[Android]Timber 사용하기 (0) | 2020.10.10 |
---|---|
NDK와 OpenCV (0) | 2020.09.30 |
EditText 관련 에러와 수정사항 (0) | 2020.09.13 |
enum 함수 (0) | 2020.07.01 |
recyclerview onresume 화면재갱신 하지 않기! (0) | 2020.06.19 |