Reputation: 2052
How do I use Retrofit 2.0
when my API returns these combinations for PUT
requests:
{ status: true }
{ status: false, info: "string value" }
{ status: false, info: "string value" }
Which model should I use? With (Boolean
and String
or String
and String
)?
And how can I get status
from this, because response
-> rawResponse
-> code
e.g. equals 500, so I should get status = false
and info = "sth"
.
Now my app crashes with (body = null
) when trying to receive this data.
Upvotes: 0
Views: 729
Reputation: 1026
You can use the below model
public class Response
{
public Boolean status;
public String info;
}
Upvotes: 0
Reputation: 157487
Which model should I use?
boolean
for status
String
for info
And how can I get status from this, cause response -> rawResponse -> code e.g. equals 500
In this case the body should be returned by Response.errorBody()
Upvotes: 1