【发布时间】:2020-07-07 20:04:14
【问题描述】:
我是改装新手,我正在尝试将字符串类型的 arraylist 发送到服务器,
我见过几个关于堆栈溢出的解决方案。
我在方法方面遇到问题。我不知道如何在方法中发送数组列表。
我尝试了两种不同的方法
方法一:
这是我的界面:
@Multipart
@PUT("profile")
Call<ProfileSetupResponse3> vendorProfile3(
@Header("access-token") String token,
@Part("name") RequestBody name,
@Part("step") RequestBody step,
@Part("description") RequestBody description,
@Part("highlights") RequestBody highlights,
@Part("minQuantity") RequestBody minQuantity,
@Part("available") RequestBody available,
@Part("warrantyDetail") RequestBody warrantyDetail,
@Part("warrentyPeriod") RequestBody warrentyPeriod,
**@Query("categories[]") ArrayList<RequestBody> categories**
);
ArrayList<RequestBody> cat = new ArrayList<>();
cat.add(createFromString("Paintsas"));
Call<ProfileSetupResponse3> call = RetrofitClient
.getInstance()
.getApi()
.vendorProfile3(....,cat)
方法二:
@Query("categories[]") ArrayList<String> categories
ArrayList<String> categories = new ArrayList<>();
categories.add("APskaoj");
categories.add("APskaoj");
categories.add("APskaoj");
Call<ProfileSetupResponse3> call = RetrofitClient
.getInstance()
.getApi()
.vendorProfile3(....,categories)
我仍然无法将我的数组列表发送到服务器。
我们将不胜感激。
【问题讨论】:
标签: android arraylist retrofit retrofit2