java.lang.IllegalArgumentException:URL查询字符串不能具有替换块

问题描述 投票:0回答:2

我正在使用翻新和GET请求:

@GET("Master/GetConsignerPartyList?prefix={claimId}")
    Observable<ConsignerPartyResponse> consignerPartyReq(@HeaderMap Map<String, String> headers, @Path("claimId") String search);

并出现此错误:

java.lang.IllegalArgumentException:URL查询字符串“ prefix = {claimId}”不能包含replace块。对于动态查询参数,请使用@Query。

怎么了?

path get retrofit2 illegalargumentexception
2个回答
0
投票

claimId是您在URL中设置的查询的一部分-?prefix={claimId}"

[@Path替换路径中的占位符,即@GET("Master/{claimId}/")

要替换查询,只需使用@Query("claimId")

@GET("Master/GetConsignerPartyList?prefix={claimId}")
Observable<ConsignerPartyResponse> consignerPartyReq(
    @HeaderMap Map<String, String> headers, 
    @Query("claimId") String search);

0
投票

从您的网址中删除?prefix = {claimId},因为查询名称在网址中不应为静态。

@GET("Master/GetConsignerPartyList")
Observable<ConsignerPartyResponse> consignerPartyReq(
              @HeaderMap Map<String, String> headers,
              @Query("prefix") String search);

它将起作用:-)

© www.soinside.com 2019 - 2024. All rights reserved.