I'm using Retrofit 2.0-beta1. How can I make a simple synchronous request and deserialize a JSON response as a POJO list? This is my interface:
public interface ArticlesAPI {
@GET("/articles")
List<ArticleResource> getArticles();
}
and
public class ArticleResource {
public String id;
public String name;
public Article toArticle() {
return new Article(id, name);
}
}
but I get this error:
> Unable to create call adapter for > java.util.List<com.bla.bla.rest.resources.ArticleResource>
Retrofit build
Retrofit retrofit = (new Retrofit.Builder()).baseUrl(this.baseUrl).build();
ArticlesAPI api = retrofit.create(ArticlesAPI.class);
This issue can also occur if you are using kotlin
coroutines
and the function is not suspend
function
public interface ArticlesAPI {
@GET("url.../habits/progress/")
suspend fun getHabitsTasks(): BaseResponse<HabitResModel>
}
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