Reputation: 1621
According to information from official site I added latest depedency and started to develop.
First I created model with data I'm interested:
public class Data{
String parametr1;
//geters and setters ommited
}
second step was to add service:
public interface GitHubService {
@GET("/repos/{owner}/{repo}")
Call<Data> repoInfos(@Path("user") String owner, @Path("repo") String repo);
Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.github.com/").build();
}
Third one was to add implementation:
@Service
public class GitHubServiceImpl implements GitHubService {
final GitHubService gitHubService = GitHubService.retrofit.create(GitHubService.class);
@Override
public Call<DetailDto> repoDetails(String owner, String repo) {
return gitHubService.repoDetails(owner, repo);
}
}
But there is an error:
java.lang.IllegalArgumentException: Could not locate ResponseBody converter for class model.Data.
Upvotes: 5
Views: 247
Reputation: 1467
For maven dependency:
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version><latest-version></version>
</dependency>
For code add a ConverterFactory:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constants.API_BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
This should do it.
Upvotes: 2