retrofit 2 @path Vs @query

后端 未结 6 409
暖寄归人
暖寄归人 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-29 23:49

    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 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.

提交回复
热议问题