【发布时间】:2020-03-15 21:12:21
【问题描述】:
我想发送包含多部分数据的数组对象。我尝试了很多方法,但它不起作用。我对贡献者参数的问题。服务器说。对于列表中的其余项目,contributor.0.id 是必需的,contributor.0.role 是必需的,依此类推。服务器读取到有一个贡献者数组并且它有项目但由于某种原因他无法提取它。
有什么帮助吗?
@Multipart
@POST("project/create")
fun createProject(
@Header("Authorization") token: String,
@Part("title") title: String,
@Part img: MultipartBody.Part,
@Part("release_date") releaseDate: String,
@Part("contributors[]") contributors: MutableList<Contributor>
): Single<Response<String>>
类贡献者
class Contributor : Serializable{
@SerializedName("id")
@Expose
var id: Int = 0
@SerializedName("role")
@Expose
var role: String = ""
}
【问题讨论】:
-
按照这个答案你会得到结果。我做到了,它对我有用。检查瓦西萨达姆答案stackoverflow.com/questions/52553210/…
标签: android kotlin retrofit rx-java