首页 > 解决方案 > 使用不同的路径参数更新 @url 路径

问题描述

Android - retrofit 2.9.0

我有以下改造方法。我正在使用 @Url 来包含基本 url 和搜索产品的路径。但是,我需要将 acode作为路径的一部分传递。由于我需要包含完整路径,如何将代码添加到完整的 url 路径中?

"https://myBaseUrl/v2/products/{code}/search"

@GET
fun searchProductV2(
    @Path("code") storeCode: String,
    @Url fullPath: String = "https://myBaseUrl/v2/products/{code}/search",
    @Query("searchCriteria[pageSize]") pageSize: String,
    @QueryMap apiSearchCriteria: Map<String, String>,
    @HeaderMap headerMap: Map<String, String> = emptyMap()
): Single<Products>

标签: androidretrofit2

解决方案


似乎是明显而简单的解决方案......

@Url fullPath: String = "https://myBaseUrl/v2/products/" +storeCode+ "/search",

推荐阅读