我想发送包含数组对象的多部分数据。我尝试过多种方法,但都无法正常工作。我的问题出在contributor参数上。服务器显示:需要contributor.0.id和contributor.0.role等其余列表中的项目。服务器读取到有一个contributor数组和其中有项,但由于某些原因无法提取它。请问有什么帮助吗?
![在Postman中如何工作(POST/form-data),我无法用Retrofit做同样的事情。](https://istack.dev59.com/oYTGu.webp)
@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 = ""
}