[英]how to POST parameters to server using retrofit2?
i want to POST data from android to server side using retrofit2 like: https://192.168.1.1/image?iname=VAR and VAR is variable from the user我想使用 retrofit2 将数据从 android 发布到服务器端,例如: https://192.168.1.1/image?iname=VAR并且 VAR 是来自用户的变量
interface ModelApi {
@POST("/image")
suspend fun pushImageToModelFromAPI(
@Body file: RequestBody,
)
}
i tried the above code but this doesn't work我试过上面的代码,但这不起作用
For query params you need to use @Query.对于查询参数,您需要使用@Query。 Like this:
像这样:
interface ModelApi {
@POST("/image")
suspend fun pushImageToModelFromAPI(
@Body file: RequestBody,
@Query("iname") name: String
)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.