retrofit 2 @path Vs @query

后端 未结 6 407
暖寄归人
暖寄归人 2021-01-29 23:25

I am new to retrofit 2 library.I read several articles to get started as a beginner and I managed to fetch XML data from my RESTful API without specifying parameters.In my metho

6条回答
  •  醉梦人生
    2021-01-30 00:13

    @Path annotation use for ordering parameters as your own way. And defined the order in url.

    @GET("user/{username}/{password}")
    Call> getUserOuth(@Path("username") String username, @Path("password") String password);
    

    @Query annotation auto order of parameters and added with url including "?" symbol.

       @GET("user")
        Call> getUserOuth(@Query("username") String username, @Query("password") String password);
    

提交回复
热议问题