retrofit2

How to release an android SDK with third party dependencies?

梦想与她 提交于 2019-12-10 19:17:32
问题 I developed an android SDK to consume our restful API. I used third party libraries like retrofit2 and rxandroid in my SDK. dependencies { compile 'io.reactivex:rxandroid:1.2.1' compile 'com.squareup.retrofit2:retrofit:2.0.2' compile 'com.squareup.retrofit2:converter-gson:2.0.2' compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2' } I released an aar file to my customer. His app imported my aar file and direct used my service which is implemented by retrofit2 to consume APIs. The problem is

Retrofit with QueryMap

Deadly 提交于 2019-12-10 18:35:31
问题 I have some request with the same endpoint but parameter and return type are different. I used @QueryMap for the parameter but I don't know how to write the return type: Must I write: @GET("xxx") Call<List<A1>> groupList1(@QueryMap Map<String, String> options); @GET("xxx") Call<List<A2>> groupList2(@QueryMap Map<String, String> options); @GET("xxx") Call<List<A3>> groupList3(@QueryMap Map<String, String> options); .... or there is a shorter solution? 回答1: You can use JsonElement response type

Parsing Soap Service use of Retrofit I am facing exception like this(i.e)mismatched body model in the class envelope model in the response

空扰寡人 提交于 2019-12-10 17:34:23
问题 While parsing response in Soap Services use of Retrofit iam facing this exception.My exception is below Failure: org.simpleframework.xml.core.ElementException: Element 'Body' does not have a match in class org.cainfo.arun.model.response.VerifyMobileResEnvelopeModel at line 1 Here is my request and response My Request <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservice.router.ees.com/"> <soapenv:Header/> <soapenv:Body> <web:verifyMobile>

How to post JSON using Retrofit 2 in android?

房东的猫 提交于 2019-12-10 17:11:01
问题 I am new to android and I dont know how to POST using retrofit I have my own server which returns me data, I need to fetch that one This is how URL body looks like I have to send "city name" taken by edittext and pass it inside "ms_data's" keyword, i.e keyword="India" This is what I have tried so far... Retrofit Builder class public class RetrofitBuilder { public static Retrofit retrofit; public static final String BASE_URL = "my url"; public static Retrofit getApiData() { if(retrofit==null)

@Order annotation has no effect on the XML serialization order

帅比萌擦擦* 提交于 2019-12-10 15:46:37
问题 I'm using Retrofit 2 with a SimpleXmlConverter and I am facing an issue when creating a Soap Request Object, that is basically an element with 4 element children each one of them being different datatypes. Here is the XML output I want to produce. The element order must be respected: <prf:container> <prf:aaa>111111111</prf:aaa> <prf:bbb>true</prf:bbb> <prf:element> <prf:ddd>50</prf:ddd> <prf:eee>false</prf:eee> </prf:element> <prf:ccc>textcontent</prf:ccc> </prf:container> Now, here is my

Retrofit Multipart with Body

ⅰ亾dé卋堺 提交于 2019-12-10 14:38:20
问题 This is how the body for the call should look like (image field will be added). { "email":"test", "username":"test", "password":"test", "name":"test", "description":"Something...", "OAuthCredentialsTest":{ "client_id":23, "client_secret":"test" } } I am using @PartMap as the body in my call: Call<CreateUserResult> createUserPart(@PartMap Map<String, RequestBody> map); And then when I enqueue the call: File file = new File(signUpUser.getImagePath()); RequestBody fileBody = RequestBody.create

Upload multiple files with PartMap Retrofit 2

我的未来我决定 提交于 2019-12-10 14:11:11
问题 When posting a new product, my server needs to catch files with keys. There's no limit to how many files. Files are unlimited. With Retrofit 1.9, everything worked perfect. After I update to Retrofit 2, my server does not receive any file. If I edit the server, it won't be backward compatible anymore. I need to make the android app works like it worked with Retrofit 1.9. Here's how I implemented. Retrofit 1.9 class to create ApiService interface. public class ApiClient { public interface

Retrofit 2.6.0 exception: java.lang.IllegalArgumentException: Unable to create call adapter for kotlinx.coroutines.Deferred

老子叫甜甜 提交于 2019-12-10 12:47:05
问题 I have a project with Kotlin coroutines and Retrofit. I had these dependencies: implementation 'com.squareup.retrofit2:retrofit:2.5.0' implementation 'com.squareup.retrofit2:converter-gson:2.5.0' implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' Today I have updated Retrofit to 2.6.0 in the project. In https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter it is written that it is deprecated now. In https://github.com/square/retrofit/blob/master

Retrofit 2.0 how to delete?

浪尽此生 提交于 2019-12-10 12:34:51
问题 I am using retrofit 2.0 and I am implementing a delete feature in my Android app, however, I cannot make it successfully, can someone give me a suggestion? I tried both: @DELETE("books/{id}") void deleteBook(@Path("id") int itemId); @DELETE("books/{id}") void deleteBook(@Path("id") int bookId, Callback<Response> callback); I get error java.lang.IllegalArgumentException: Service methods cannot return void. for method LibraryService.deleteBook. I also gave a try on this: Response deleteBook(

Retrofit 2.0 throwing “IllegalArgumentException: @Field parameters can only be used with form encoding”. How to do right API query and fix it?

霸气de小男生 提交于 2019-12-10 12:28:06
问题 My problem is that I don't know how to start using Retrofit 2.0 with received API - mentioned below... Firstly, I need to username, password, fbID (optional), gmailID (optional), twitID (optional), gender, birthDate, location (not required - if long and lat has values), longitude (optional), latitude (optional), profileImage (optional). When all parameters are good - receive status = true . If not - receive status = false and required parameters which are wrong (e.g. mail is already taken) So