How to pass string in 'Body' Parameter of Retrofit 2 in android How to pass string in 'Body' Parameter of Retrofit 2 in android json json

How to pass string in 'Body' Parameter of Retrofit 2 in android


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.