问题
I am beginner in retrofit... I need send POST request with simple parameters
name : value
- login[name] : some-name
- login[pw] : some-pw
- date : 2017-08-28T12:12:12+0200
so, I tried
@FormUrlEncoded
@POST(urlLogin)
Call<Login> signIn(@Field("login[name]") String name,
@Field("login[pw]") String pw,
@Field("date") String date);
that send to the server:
- login%5Bname%5D : some-name
- login%5Bpw%5D : some-pw
- date : 2017-08-28T21%3A11%3A57%2B0200
next
@FormUrlEncoded
@POST(urlLogin)
Call<Login> signIn(@Field(value = "login[name]", encoded = true) String name,
@Field(value = "login[pw]", encoded = true) String pw,
@Field(value = "date", encoded = true) String date);
gives:
- login%5Bname%5D : some-name
- login%5Bpw%5D : some-pw
- date : 2017-08-28T19%3A59%3A04+0200
next
@FormUrlEncoded
@POST(urlLogin)
Call<Login> signIn(@FieldMap Map<String, String> fieldsMap);
gives:
- login%5Bname%5D : some-name
- login%5Bpw%5D : some-pw
- date : 2017-08-28T21%3A11%3A57%2B0200
next
@FormUrlEncoded
@POST(urlLogin)
Call<Login> signIn(@FieldMap(encoded = true) Map<String, String> fieldsMap);
gives:
- login%5Bname%5D : some-name
- login%5Bpw%5D : some-pw
- date : 2017-08-28T19%3A59%3A04+0200
please, help me, what do i wrong? what wrong with date? why "+" are disabled for encoding and ":" are encoded? and why parameters name are encoded and how to disable this?
来源:https://stackoverflow.com/questions/45925251/retrofit-2-disable-encoding-for-post-parameters