@POST("api/login")
Call<ApiResponse> loginUser(@Body String user);
Here the string is actually a JSONstring ie
{"email":"test@gmail.com","password":"test"}
Couldnt figure out what is wrong in this. Either the string it again converted to json. Please suggest..
This is what i want to do to my request as shown in picture.
Convert your data in object
public class Credentials
{
public String email;
public String password;
}
Set the data to object
Credentials loginCredentials = new Credentials();
loginCredentials.email = "test@gmail.com";
loginCredentials.password = "password";
Call your api
@POST("api/login")
Call<ApiResponse> loginUser(@Body Credentials credentials);
@POST("api/login")
Call<ApiResponse> loginUser(@Body HashMap<String, String> user);
We can use Hasmap here like this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.