y07k2
y07k2

Reputation: 2052

Basic use of Retrofit 2.0 with PUT method

How do I use Retrofit 2.0 when my API returns these combinations for PUT requests:

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

Answers (2)

Dotnetpickles
Dotnetpickles

Reputation: 1026

You can use the below model

public class Response
{
  public Boolean status;
  public String info;
}

Upvotes: 0

Blackbelt
Blackbelt

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

Related Questions