如何在 body 中使用两个字段进行改造
How to use two fields in body for methos put in retrofit
我有两个字符串,我应该将它们设置在我的放置请求的正文中。如何通过改造做到这一点?
@PUT("/user-management/Account/activate")
@FormUrlEncoded
@Headers({ "Content-Type: application/json"})
Call<Verification> activation(@Part("code") String code , @Part("token") String token);
您可以尝试我在下面 post 编辑的类似代码:有关详细代码,请 post 您的上下文或部分代码。
@Multipart
@PUT("user/photo")
Call<User> updateUser(@Part("photo") RequestBody photo, @Part("description") RequestBody description);
您可以像这样在 Body 中传递多个字符串:
创建 Class
public class Verification
{
public String code;
public String token;
}
将数据设置为对象
Verification loginCredentials = new Verification();
loginCredentials.code= "12345;
loginCredentials.token= "54321";
打电话给你的api
@PUT("/user-management/Account/activate")
Call<Verification> activation(@Body Verificationcredentials);
我有两个字符串,我应该将它们设置在我的放置请求的正文中。如何通过改造做到这一点?
@PUT("/user-management/Account/activate")
@FormUrlEncoded
@Headers({ "Content-Type: application/json"})
Call<Verification> activation(@Part("code") String code , @Part("token") String token);
您可以尝试我在下面 post 编辑的类似代码:有关详细代码,请 post 您的上下文或部分代码。
@Multipart
@PUT("user/photo")
Call<User> updateUser(@Part("photo") RequestBody photo, @Part("description") RequestBody description);
您可以像这样在 Body 中传递多个字符串:
创建 Class
public class Verification
{
public String code;
public String token;
}
将数据设置为对象
Verification loginCredentials = new Verification();
loginCredentials.code= "12345;
loginCredentials.token= "54321";
打电话给你的api
@PUT("/user-management/Account/activate")
Call<Verification> activation(@Body Verificationcredentials);