我有一个形式的改装请求
https://my_base_url/customer_id/file_name?query1=value1&query2=value2&query3=value3&query4=value4
所以我在接口中声明请求为
@GET("{customer_id}/{file_name}")
@Streaming
suspend fun getFilePart(
@Path(value = "customer_id") customerId: Int,
@Path(value = "file_name") filename: String,
@QueryMap queryMap: Map<String, String>
): ResponseBody
然而,由于我的应用程序的Api,我从querMap中得到的是整个String作为一个参数,queryMap的键每次都不一样。所以我想要的是一种将整个queryMap作为一个String传递的方法。下面有类似的东西
@GET("{customer_id}/{file_name}?${wholeQueryAsaString}")
@Streaming
suspend fun getFilePart(
@Path(value = "customer_id") customerId: Int,
@Path(value = "file_name") filename: String,
wholeQueryAsaString: String
): ResponseBody
其中wholeQueryAsaString具有值query1=value1&query2=值2&query3=value3&query4=value4
我该怎么做?
试试这个
val queryMap: HashMap<String, String> = HashMap()
map["value1"] = query1
map["value2"] = query2
map["value3"] = query3
@GET("{customer_id}/{file_name}")
@Streaming
suspend fun getFilePart(
@Path(value = "customer_id") customerId: Int,
@Path(value = "file_name") filename: String,
@FieldMap queryMap: HashMap<String, String>
): ResponseBody