retrofit

Multipart request with Retrofit @PartMap Error in Kotlin (Android)

核能气质少年 提交于 2020-01-11 18:41:08
问题 If I am using this code in Java then its working fine. When I convert that code in kotlin then I got Error. Logcat 08-20 23:46:51.003 3782-3782/com.qkangaroo.app W/System.err: java.lang.IllegalArgumentException: Parameter type must not include a type variable or wildcard: java.util.Map (parameter #1) 08-20 23:46:51.003 3782-3782/com.qkangaroo.app W/System.err: for method ApiInterface.updateCustomerDetail 08-20 23:46:51.003 3782-3782/com.qkangaroo.app W/System.err: at retrofit2.ServiceMethod

How to transform a nested list of double values into a Java class using RxJava?

眉间皱痕 提交于 2020-01-11 12:23:14
问题 In my Android client I receive this JSON data from a backend: [ [ 1427378400000, 553 ], [ 1427382000000, 553 ] ] Here is the routine which actually loads the data. I am using RxAndroid and Retrofit here. private void getProductLevels() { Observable<List<List<Double>>> responseObservable = mProductService.readProductLevels(); AppObservable.bindFragment(this, responseObservable) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) // TODO: Transform List<List<Double>> into

Any way to have generic URL using Retrofit

☆樱花仙子☆ 提交于 2020-01-11 11:24:08
问题 I have several URL that accepts the same GET parameters (mainly for pagination purposes) as follow : public interface AsynchronousApi { @GET("/api/users") public void listUsers(@Query("limit") Integer limit, @Query("offset") Integer offset, Callback<userList> callback); @GET("/api/posts") public void listPosts(@Query("limit") Integer limit, @Query("offset") Integer offset, Callback<postList> callback); ... } Since I have lots of URL, this is getting a bit repetitive. So I would like to have

Retrofit android not working and has no error

旧城冷巷雨未停 提交于 2020-01-11 10:47:14
问题 I just implemented the retrofit android library for rest api call but it is not working and has no error. My code is ApiInterface.java public interface ApiInterface { @POST("url") void getLoginResponse(@Field("username") String username , @Field("password") String password, @Field("clientId") String clientId , Callback<LoginResponse> cb); } RestClient.java public class RestClient { private static ApiInterface REST_CLIENT; private static String BASE_URL = "base_url"; static { setupRestClient()

Retrofit, how to parse JSON objects with variable keys

心不动则不痛 提交于 2020-01-11 09:51:30
问题 First I know my title is bad as I didn't come up with better, I'm opened to suggestion. I'm using retrofit to get data from an api of this kind : @GET("users/{userid}") It works fine and I'm happy with it, the problem is when I call the same api with @POST("users/widget") with a list of ids. I have the following answer : { "long_hash_id": { "_id": "long_hash_id" ....... }, "long_hash_id": { "_id": "long_hash_id", ..... }, ........ } the "long_hash_id" is typicaly "525558cf8ecd651095af7954" it

Retrofit, how to parse JSON objects with variable keys

妖精的绣舞 提交于 2020-01-11 09:51:20
问题 First I know my title is bad as I didn't come up with better, I'm opened to suggestion. I'm using retrofit to get data from an api of this kind : @GET("users/{userid}") It works fine and I'm happy with it, the problem is when I call the same api with @POST("users/widget") with a list of ids. I have the following answer : { "long_hash_id": { "_id": "long_hash_id" ....... }, "long_hash_id": { "_id": "long_hash_id", ..... }, ........ } the "long_hash_id" is typicaly "525558cf8ecd651095af7954" it

Multipart Request using Retrofit 1.8.0 not working

让人想犯罪 __ 提交于 2020-01-11 05:15:29
问题 I have like 4 days, trying to make a Multipart Request using Retrofit 1.8.0 in android with any success. My interface looks something like this @Multipart @POST("/posts/add.json") void addComment( @Part("id") String id, @Part("post[body]") String body, @Part("post[attachment]") TypedFile attachment, Callback<Map<String, String>> callback ); But, in the server side, I receive the following Parameters: {"id"=># <File:/var/folders/z0/0ggjvvfj4t1fdsvbxf3lc9pw0000gn/T/RackMultipart9853-0>, "post"=

Multipart Request using Retrofit 1.8.0 not working

与世无争的帅哥 提交于 2020-01-11 05:15:11
问题 I have like 4 days, trying to make a Multipart Request using Retrofit 1.8.0 in android with any success. My interface looks something like this @Multipart @POST("/posts/add.json") void addComment( @Part("id") String id, @Part("post[body]") String body, @Part("post[attachment]") TypedFile attachment, Callback<Map<String, String>> callback ); But, in the server side, I receive the following Parameters: {"id"=># <File:/var/folders/z0/0ggjvvfj4t1fdsvbxf3lc9pw0000gn/T/RackMultipart9853-0>, "post"=

Format of POJO for nested JSON?

眉间皱痕 提交于 2020-01-11 03:40:11
问题 So lets say the JSON response is: [{ "data" : { "item1": value1, "item2:" value2 }}] How do you get the values 'value1' and 'value2' when you must first access data? If the fields were at the root then I could just have the method return a POJO with those field names. I basically want the below to work. @GET("/path/to/data/") Pojo getData(); class Pojo { public String item1; public String item2; } 回答1: You can try below code to convert your json string to Pojo object with required fields

Chaining two web service calls using RxJava and Retrofit

风格不统一 提交于 2020-01-11 03:26:26
问题 I am using RxJava and Retrofit.My basic requirement is,i want to chain two api calls, which will get called one after one another. Response received from first api is used as input while calling second api. After reading some stuff on internet i used to flatmap to achieve this. While carrying out this operation i am showing loader.Sometimes it runs smoothly but on some occasions this loader freezes. DDMS shows log of "skipped 300 frames,Application may be doing too much work on its main