如何在多部分改装请求中发送对象数组

问题描述 投票:0回答:1

我想发送包含多部分数据的数组对象。我尝试了很多方法,但是没有用。我的贡献者参数问题。服务器说。对于列表中的其余项目,需要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 = ""

}

我想发送包含多部分数据的数组对象。我尝试了很多方法,但是没有用。我的贡献者参数问题。服务器说。 contributor.0.id是必填项,并且contributor.0.role ...

android kotlin retrofit rx-java
1个回答
0
投票

使用@Field

© www.soinside.com 2019 - 2024. All rights reserved.