retrofit2

Custom converter for Retrofit 2

拟墨画扇 提交于 2019-12-17 06:11:23
问题 I have to handle a dynamic JSON responses. Before, I was using classes and annotations as follows: public class ChatResponse { @SerializedName("status") private int status; @SerializedName("error") private String error; @SerializedName("response") private Talk response; public int getStatus() { return status; } public String getError() { return error; } public Talk getResponse() { return response; } } When the status is 1 (success) the onResponse is fired and I can get a ChatResponse object.

Custom converter for Retrofit 2

拥有回忆 提交于 2019-12-17 06:11:04
问题 I have to handle a dynamic JSON responses. Before, I was using classes and annotations as follows: public class ChatResponse { @SerializedName("status") private int status; @SerializedName("error") private String error; @SerializedName("response") private Talk response; public int getStatus() { return status; } public String getError() { return error; } public Talk getResponse() { return response; } } When the status is 1 (success) the onResponse is fired and I can get a ChatResponse object.

Retrofit and RxJava: How to combine two requests and get access to both results?

孤者浪人 提交于 2019-12-17 06:10:10
问题 I need to make two requests for services and combine it results: ServiceA() => [{"id":1,"name":"title"},{"id":1,"name":"title"}] ServiceB( id ) => {"field":"value","field1":"value"} Currently, I have managed to combine the results, but I need to pass id as a parameter to the ServiceB and get access to the first result. What I tried so far: Retrofit repo = new Retrofit.Builder() .baseUrl("https://api.themoviedb.org/3/genre/") .addConverterFactory(GsonConverterFactory.create())

Retrofit 2: Get JSON from Response body

泪湿孤枕 提交于 2019-12-17 02:43:29
问题 I want to get string json from my api using retrofit 2, I have no problem when using retrofit 1 to get this json but using retrofit 2 returns null for me. This is what my json looks like {"id":1,"Username":"admin","Level":"Administrator"} This is my API @FormUrlEncoded @POST("/api/level") Call<ResponseBody> checkLevel(@Field("id") int id); This is how my code looks like Retrofit retrofit = new Retrofit.Builder() .baseUrl(Config.BASE_URL) .addConverterFactory(GsonConverterFactory.create())

ArrayIndexOutOfBoundsException - Retrofit Call

杀马特。学长 韩版系。学妹 提交于 2019-12-14 04:17:27
问题 I am trying to call a PUT method on my Retrofit instance: Response<UpdateUserProfileResponse> response = App.getService().updateUserProfile(//A good 26 parameters).execute(); The parameters in the updateUserProfile() are a mixture of String, Boolean and one List<MyObject> . When I call this method, I get the following error: Throwing new exception 'length=238; index=1366' with unexpected pending exception: java.lang.ArrayIndexOutOfBoundsException: length=238; index=1366 06-28 21:53:12.458

Retrofit2 Unauthenticated 401 error when using rxjava2

谁说我不能喝 提交于 2019-12-14 03:48:59
问题 Ever since i'v integrated RxJava2 , i am receiving 401 unauthenticated error in all retrofit calls that return Observable , i'm using basic authentication and i know error is due to it , but why it works on debug but not release. In my opinion something is wrong with the configuration for rxjava adapters of retrofit2 Stack Trace: com.jakewharton.retrofit2.adapter.rxjava2.HttpException: HTTP 401 Unauthorized 01-22 19:24:14.872 11502-11502/? W/System.err: at com.jakewharton.retrofit2.adapter

RxJavaCallAdapterFactory cannot be converted to Factory

旧街凉风 提交于 2019-12-14 03:43:45
问题 I'm trying to use Retrofit 2 and RxJava following the guide in this https://inthecheesefactory.com/blog/retrofit-2.0/en In section "RxJava Integration with CallAdapter " explains how use RxJava with retrofit Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://api.nuuneoi.com/base/") .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build(); However during compilation there is the following error: Error:(63, 71) error:

how to use Retrofit in Android? [closed]

南楼画角 提交于 2019-12-14 03:32:51
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I am having a hard time in understanding the Retrofit for my App. I want to use retrofit in it but I am not understanding about it much. Everthing is very confusing in it. Can any one help me to learn it completely I dont know how to start and from where to start The links I have

How to send PUT request with retrofit string and array list of model I need to use URL encoded

孤街醉人 提交于 2019-12-14 03:27:50
问题 can anyone guide me how to send PUT request with this json { "delivery_status": "Partially Completed", "signatures": "==skdjfkjdsakjhfoiuewyrdskjhfjdsaf", "assignee_note": "this is remarks and and and nothing", "id": "this is remarks and and and nothing", "returned_products": [ { "id": "18", "quantity": 3, "reasons": "i dont know reason .. bus wapis a gya saman :-)" }, { "id": "19", "quantity": 4, "reasons": "i dont know reason .. bus wapis a gya saman :-)" } ] } here is what i have tried but

Retrofit RxAndroid make wrapper for api calls

柔情痞子 提交于 2019-12-14 02:06:18
问题 I wanted to create a wrapper for api calls in retrofit so I can display ProgressDialog at common place & handle common response. I achieved this by creating wrapper like this public static <T> Observable<T> callApiWrapper(final Context context, final boolean shouldShowProgress, final String message, final Observable<T> source) { final ProgressDialog progressDialog = new ProgressDialog(context); if (shouldShowProgress) { if (!TextUtils.isEmpty(message)) progressDialog.setMessage(message); else