Retrofit 2.0-beta-2 is adding literal quotes to MultiPart values

后端 未结 7 1756
终归单人心
终归单人心 2020-12-11 00:18

Went to upgrade to Retrofit 2.0 and running into this weird problem.

I have a method to log a user in

public interface ApiInterface {

    @Multipart         


        
7条回答
  •  盖世英雄少女心
    2020-12-11 00:51

    I don't know if it is too late, but we can also send requests with RequestBody.

    Example:

    public interface ApiInterface {
       @Multipart
       @POST("user/login/")
       Call userLogin(@Part("username") String username, @Part("password") String password);
    }
    

    We can convert as below:

    public interface ApiInterface {
       @Multipart
       @POST("user/login/")
       Call userLogin(@Part("username") RequestBody username, @Part("password") String password);
    }
    

提交回复
热议问题