retrofit2

Send complex object using Retrofit2

别说谁变了你拦得住时间么 提交于 2020-05-17 07:43:05
问题 I'm trying to send a complex object as a parameter of my request using Retrofit2 and Kotlin. Structure of that object is the following: { "id": "..." "token": "..." "message": "..." "list1": [ { "id": 1, "value": 2 }, { "id": 2, "value": 5 } //and so on... ] "list2": [ { "id": 10, "value": 16 }, { "id": 11, "value": 21 } //and so on... ] //and so on... } The number of list fields is various (could be 2 lists, could be 10) as well as the number of items inside each list. I'm using the

How to get the value with GSON / Retrofit? [duplicate]

。_饼干妹妹 提交于 2020-05-17 04:21:08
问题 This question already has answers here : Using GSON to parse a JSON array (4 answers) Closed 2 years ago . How to extract the value of "text" by using GSON/Retrofit? { code: 200, lang: "en-ms", text: [ "Burung" ] } 回答1: 1 Create your model class public class ResponseItem { /** * code : 200 * lang : en-ms * text : ["Burung"] */ private int code; private String lang; private List<String> text; public int getCode() { return code; } public void setCode(int code) { this.code = code; } public

How to get the value with GSON / Retrofit? [duplicate]

泄露秘密 提交于 2020-05-17 04:20:06
问题 This question already has answers here : Using GSON to parse a JSON array (4 answers) Closed 2 years ago . How to extract the value of "text" by using GSON/Retrofit? { code: 200, lang: "en-ms", text: [ "Burung" ] } 回答1: 1 Create your model class public class ResponseItem { /** * code : 200 * lang : en-ms * text : ["Burung"] */ private int code; private String lang; private List<String> text; public int getCode() { return code; } public void setCode(int code) { this.code = code; } public

How to get the value with GSON / Retrofit? [duplicate]

China☆狼群 提交于 2020-05-17 04:19:02
问题 This question already has answers here : Using GSON to parse a JSON array (4 answers) Closed 2 years ago . How to extract the value of "text" by using GSON/Retrofit? { code: 200, lang: "en-ms", text: [ "Burung" ] } 回答1: 1 Create your model class public class ResponseItem { /** * code : 200 * lang : en-ms * text : ["Burung"] */ private int code; private String lang; private List<String> text; public int getCode() { return code; } public void setCode(int code) { this.code = code; } public

retrofit interceptor on different module in feature-based clean-architecture android

帅比萌擦擦* 提交于 2020-05-16 21:58:12
问题 I've been learning clean architecture with refrence to this-sample and some others, with which I just created a base module, such that all the modules in my project must be implementing it. Here I keep all the Utility classes as well. It helped me a lot to be lazy on basic project setup for dagger, retrofit, etc. I thus got faster easy way on diving into the clean-architecture with feature-based modules. I've managed my project files in this manner. The main problem I faced with this

POST data with retrofit2, Bearer token Unauthorized android

喜欢而已 提交于 2020-05-16 06:25:42
问题 I want to post new data to server with this JSON: { "tgl_Lahir": "1990-12-18 00:00:00", "nama": "Joe", "keterangan": "Employee", "tempatLahir": "Los Angeles", "noPegawai": "111111", "golDarah": "0", "statusNikah": "0", "hubungans": { "id": "10" }, "agama": { "id_Agama": "1" }, "jeniskelamin": { "jenisKelamin": "1" } } Here's my ApiClientPOST.java: public class ApiClientPOST { private static Retrofit retrofit = null; public static Retrofit getClient(String url){ if(retrofit == null){ retrofit

Retrofit POST java.io.IOException: unexpected end of stream on Connection caused by java.io.EOFException: \n not found:

穿精又带淫゛_ 提交于 2020-05-15 08:04:54
问题 I have went through all the question related to this and yet, I haven't found a solution that works for me. Im using retrofit 2.8.1 and OkHttp 4.5.0 . My service interface looks like the following public interface MlApiService { @POST @Multipart Call<List<PreprocessedDocument>> postDocument( @Url String apiUrl, @Part MultipartBody.Part document, @Part ( "document_id") RequestBody documentId ); } And I build the client like the following with requestTimeoutInSeconds set to 90 seconds. public

Rxjava 3 + Retrofit2 - multiple inserts to DB problem

风格不统一 提交于 2020-05-15 06:26:38
问题 I am trying to do the following; sync a cloud DB using Retrofit to a local SqLite DB (Room) on a device. The DB could get large, around 100,000 registers or more, so the sync process can take some time. So it send a first Retrofit request to get the number of register, so it can calculate the total number of pages, after that it will send multiple Retrofit Request, to get all the data from API, after each request, it saves the data to Room. Right now, I am having trouble combining two RxJava

Rxjava 3 + Retrofit2 - multiple inserts to DB problem

[亡魂溺海] 提交于 2020-05-15 06:26:25
问题 I am trying to do the following; sync a cloud DB using Retrofit to a local SqLite DB (Room) on a device. The DB could get large, around 100,000 registers or more, so the sync process can take some time. So it send a first Retrofit request to get the number of register, so it can calculate the total number of pages, after that it will send multiple Retrofit Request, to get all the data from API, after each request, it saves the data to Room. Right now, I am having trouble combining two RxJava

How to use flatMap in Android RxJava to make three web service call sequentially without using lambda function?

烂漫一生 提交于 2020-05-14 18:26:07
问题 My API Client public class ApiClient { public static final String BASE_URL = "http://baseurl.com/wp-json/"; private static Retrofit retrofit = null; public static Retrofit getClient() { if (retrofit==null) { retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .build(); } return retrofit; } } My endpoint interface public interface ApiInterface { @GET("posts/category/politics/recent