I have a web query with JSON response as:
{
"status":true,
"result":
{
"id":"1",
"name":"ABC 1",
"email":"[email protected]",
"password":"123456",
"status":false,
"created":"0000-00-00 00:00:00"
},
"message":"Login successfully"
}
I am using the following code for:
@GET("/stockers/login")
public void login(
@Query("email") String email,
@Query("password") String password,
Callback<JSONObject> callback);
In Debugger the query made by the Retrofit library is correct, however I get an empty JSON in response.
ApiManager.getInstance().mUrlManager.login(
email.getText().toString().trim(),
password.getText().toString().trim(),
new Callback<JSONObject>()
{
@Override
public void success(JSONObject jsonObj, Response response)
{
mDialog.dismiss();
The Best Answer is The @Body annotation defines a single request body. Since Retrofit uses Gson by default, the FooRequest instances will be serialized as JSON as the sole body of the request. The Gson docs have much more on how object serialization works. And then use an instance of that class similar to #1.
Simply use JsonElement
insted of JSONobject
. Like:
@GET("/stockers/login")
Call<JsonElement> getLogin(
@Query("email") String email,
@Query("password") String password
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With