Questions tagged [retrofit]

Retrofit is a type-safe REST client for Android and Java by Square, Inc.

Retrofit turns REST API into a Java interface.

public interface GitHubService {
  @GET("/users/{user}/repos")
  List<Repo> listRepos(@Path("user") String user);
}

The RestAdapter class generates an implementation of the GitHubService interface.

RestAdapter restAdapter = new RestAdapter.Builder()
   .setEndpoint("https://api.github.com")
   .build();

GitHubService service = restAdapter.create(GitHubService.class);

Each call on the generated GitHubService makes an HTTP request to the remote webserver.

List<Repo> repos = service.listRepos("octocat");

Annotations are used to describe the HTTP request:

  • URL parameter replacement and query parameter support
  • Object conversion to request body (e.g., JSON, protocol buffers)
  • Multipart request body and file upload

The library is open sourced under Apache 2.0 license.

References

8574 questions
3
votes
1 answer

Retrofit RxJava Simple test

I'm learning Retrofit and RxJava and I'v created test to connect github: public class GitHubServiceTests { RestAdapter restAdapter; GitHubService service; @Before public void setUp(){ Gson gson = new GsonBuilder() …
3
votes
1 answer

How to get a value from strings.xml in a retrofit interface?

We're using retrofit android client (http://square.github.io/retrofit/) for network calls to our server and I cant figure out how to access values in the strings.xml file from the interface class that we created for retrofit. Here's a small sample…
Cody
  • 870
  • 4
  • 21
  • 38
3
votes
1 answer

How to use Digest authentication in Android Retrofit?

I am creating an Android application that request to a server authenticated by digest authentication method. I am using Retrofit to do the requests. Can someone explain me how to do this?
congtrungvnit
  • 635
  • 1
  • 10
  • 16
3
votes
2 answers

Default/Constant values for POST/PUT arguments with Retrofit

Using the Retrofit REST Client library from Square, is there anyway of providing default/constant values for POST/PUT fields in a call. I know about including constant query parameters by simply including them in the path, but this work for Body…
Mark Derricutt
  • 979
  • 1
  • 11
  • 20
3
votes
3 answers

Proguard config to use retrofit Retrofit

my app is running all ok in debug, but when creating apk to release, I'm getting the follow error. Process: neocom.dealerbook, PID: 9044 java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 at…
wviana
  • 1,619
  • 2
  • 19
  • 47
3
votes
1 answer

java annotation for url - what is use case?

Im trying to figure out what a annotation does that is created in code i have inherited. Here is the annotation definition per code: import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
3
votes
1 answer

Logging Retrofit to Logback Logger

I'm developing a JAVA client for a REST API. I'm using Retrofit for the client. I see that I can set log level when creating adapter in retrofit. All this log currently goes to console. However, I want to redirect this to the log generated by…
TechCrunch
  • 2,924
  • 5
  • 45
  • 79
3
votes
2 answers

Android Retrofit: missing method body, or declare abstract

I am writing an android app that will use Retrofit to make API requests. I have a helper class like this: public class ApiService { public static final String TAG = ApiService.class.getSimpleName(); public static final String BASE_URL =…
johncorser
  • 9,262
  • 17
  • 57
  • 102
3
votes
1 answer

How to use callback for multiple json array in retrofit?

I am trying retrofit how to get data from below response { "schedule_students": [ { "id": "753", "sch_id": "153" }, { "id": "765", "sch_id": "153" } ], "s_students": [ { "id": "753", …
Mathankumar K
  • 117
  • 2
  • 8
3
votes
1 answer

Transform RxJava observable's error into another observable and swallow success

How do I transform observable's error to another observable? I am trying to implement algorithm showed on scheme below: I am using a tutorial named Grokking RxJava to start my learning and found that flatMap operator can convert one Observable…
3
votes
1 answer

Retrofit: Expected BEGIN_OBJECT but was BEGIN_ARRAY

Sorry for one more question about this error, but everything that I've read was helpless for me. I'm using Retrofit Library and GSON for parse JSON answers. I got this error: E/RETROFIT ERROR﹕ com.google.gson.JsonSyntaxException:…
Alex
  • 76
  • 2
  • 7
3
votes
1 answer

How to move retrofit's Callback from Activity to class

I used to have my createBottomBar() within Activity. Since Activity passed 4-5 hundreds lines I moved it to a separate class but now I dont know how to access my updateMap(). updateMap code is : private void updateMap(String path) { …
vicolored
  • 815
  • 2
  • 10
  • 20
3
votes
1 answer

How can I get the results returned by a map function with RxJava?

I am getting a list of multimedia information as part of my API call using RxJava's map function to create a list of image URLs from the response JSON. How can I handle the returned list from the map function? This is my code: BrowseAPI service =…
rahul.ramanujam
  • 5,608
  • 7
  • 34
  • 56
3
votes
1 answer

RxJava - Combining multiple/different web service calls

I'm working with the Basecamp api to return and display to do lists. Here's a sample of what I'm doing at the moment: bcxClient .fetchToDoLists() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new…
Mitkins
  • 4,031
  • 3
  • 40
  • 77
3
votes
1 answer

ERROR﹕ javax.net.ssl.SSLHandshakeException, failure in SSL library?

Using retrofit library in my Android app for a long time. Now the app stopped working, with an error message: ERROR﹕ javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xb9753f20: Failure in SSL…
jalle
  • 39
  • 1
  • 5