Reputation: 51
I would like to do a POST Command.
This is my endpoint: http://180.150.134.136:18095/WSCoreAPI/send/receive/tester?method=LOGN&data=(urlencodeddata)
my question is how will i structure the endpoint in my retrofit
i did something like this:
@POST("WSCoreAPI/send/receive/tester")
Call<LoginResponse> tester(
@QueryMap Map<String, String> data);
but it is not working
as well as this:
@POST("WSCoreAPI/send/receive/tester")
Call<LoginResponse> tester(
@Query("method") String method,
@Query("data") String data);
Upvotes: 1
Views: 3515
Reputation: 51
Okay so I got it working.
I used either two of the above solutions.
what i did was i removed the url encoding of the "data" query params and used this:
@FormUrlEncoded
@POST("WSCoreAPI/send/receive/tester")
Call<LoginResponse> tester(@Field("method") String method,
@Field("data") String data);
removing the url encoding fix the problem because retrofit will automatically encode the fields annotated with @Field
Upvotes: -1
Reputation: 1512
try this
@FormUrlEncoded
@POST("WSCoreAPI/send/receive/tester")
Call<LoginResponse> tester(@FieldMap Map<String, String> parameters);
Upvotes: 1
Reputation: 2266
Use @Field and @FormUrlEncoded for url encoded fields
@FormUrlEncoded
@POST("WSCoreAPI/send/receive/tester")
Call<LoginResponse> tester(@Field("method") String method,
@Field("data") String data);
Upvotes: 1