retrofit

Retrofit 2: How to set individual timeouts on specific requests?

痴心易碎 提交于 2021-01-21 03:32:12
问题 I have set a global timeout in my Retrofit adapter by doing OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.setReadTimeout(20, TimeUnit.SECONDS); okHttpClient.setConnectTimeout(20, TimeUnit.SECONDS); retrofit = new Retrofit.Builder() .client(okHttpClient) .build(); Great! But I would like to set an specific timeout for certain requests E.g. public interface MyAPI { @GET() Call<Void> notImportant (@Url String url); @GET Call<Void> veryImportant(@Url String url); So veryImportant

How to parse data of WordPress REST API using Retrofit and GSON?

99封情书 提交于 2021-01-07 03:45:39
问题 i have this type of JSON data and i have a problem on parsing list of data! THIS IS MY JSON DATA [ { "id": 17502, "link": "https://www.angrybirds.com/blog/get-ready-angry-birds-movie-2-premiere-new-game-events/", "title": { "rendered": "Get ready for The Angry Birds Movie 2 premiere with new in-game events!" }, "excerpt": { "rendered": "<p>The Angry Birds Movie 2 comes to US theaters tomorrow, but who wants to wait that long?! Good news: you can get into the movie mood right now with a new

Special characters are encoded in POST request in android. How to avoid this?

妖精的绣舞 提交于 2021-01-07 02:42:58
问题 I am calling a post API with some parameters. one the parameters is activatecode="aaaaaa$rr" when the API call is made, it is sent as activatecode=aaaaaa%24rr The $ is encoded as %24. How to avoid this and send the special character as it is? 来源: https://stackoverflow.com/questions/65409306/special-characters-are-encoded-in-post-request-in-android-how-to-avoid-this

Special characters are encoded in POST request in android. How to avoid this?

让人想犯罪 __ 提交于 2021-01-07 02:42:08
问题 I am calling a post API with some parameters. one the parameters is activatecode="aaaaaa$rr" when the API call is made, it is sent as activatecode=aaaaaa%24rr The $ is encoded as %24. How to avoid this and send the special character as it is? 来源: https://stackoverflow.com/questions/65409306/special-characters-are-encoded-in-post-request-in-android-how-to-avoid-this

How to parse JSON object with array retrofit [duplicate]

孤街浪徒 提交于 2021-01-05 09:47:47
问题 This question already has answers here : Accessing members of items in a JSONArray with Java (6 answers) Closed 1 year ago . how to fetch JSON object with array using android retrofit. I am using retrofit as web API. My JSON Response is as follows:- { "PnrNumber": "12345665", "Status": "SUCCESS", "ResponseCode": "200", "TrainNumber": "1111", "TrainName": "ABC", "JourneyClass": "SL", "ChatPrepared": "NO", "From": "TEST1", "To": "TEST2", "JourneyDate": "2019-10-01", "Passangers": [ { "Passenger

Dynamically add query parameters without value to Retrofit request

穿精又带淫゛_ 提交于 2021-01-02 05:00:06
问题 I have request that set list of services that are turned on for user. Request has following format: https://myserver.com/setservices?param1=val1&param2=val2&service[10]&service[1000]&service[10000] List of service parameters ("service[10]&service[1000]&service[10000]") is created dynamically and each parameter doesn't have value. Is it possible to achive this using Retrofit? 回答1: From the retrofit documentation: For complex query parameter combinations a Map can be used. @GET("/group/{id}

How to trust SSL certificates with cross-signed root expired on android <= 5

…衆ロ難τιáo~ 提交于 2020-12-31 13:55:34
问题 I work for a company that uses a Comodo/Sectigo SSL certificate. But suddenly our app started throwing this error when sending POST to the server, in versions with android 4 and 5, with Okhttp client. HTTP FAILED: javax.net.ssl.SSLHandshakeException: com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate expired at Sat May 30 05:48:38 CDT 2020 (compared to Mon Jun 08 23:13:02 CDT 2020) I tried many StackOverflow solutions, without

How to trust SSL certificates with cross-signed root expired on android <= 5

十年热恋 提交于 2020-12-31 13:47:33
问题 I work for a company that uses a Comodo/Sectigo SSL certificate. But suddenly our app started throwing this error when sending POST to the server, in versions with android 4 and 5, with Okhttp client. HTTP FAILED: javax.net.ssl.SSLHandshakeException: com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate expired at Sat May 30 05:48:38 CDT 2020 (compared to Mon Jun 08 23:13:02 CDT 2020) I tried many StackOverflow solutions, without

How to trust SSL certificates with cross-signed root expired on android <= 5

杀马特。学长 韩版系。学妹 提交于 2020-12-31 13:46:33
问题 I work for a company that uses a Comodo/Sectigo SSL certificate. But suddenly our app started throwing this error when sending POST to the server, in versions with android 4 and 5, with Okhttp client. HTTP FAILED: javax.net.ssl.SSLHandshakeException: com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate expired at Sat May 30 05:48:38 CDT 2020 (compared to Mon Jun 08 23:13:02 CDT 2020) I tried many StackOverflow solutions, without

面世宣言:给 Android 开发者的面试手册

徘徊边缘 提交于 2020-12-23 14:10:25
这个系列不是最好的了? 对,再也不敢说「 这可能是最好的 XXX」了。虽然我的 RxJava 2.0 系列 获得了较好的反馈,甚至还有人说「能望见传世神文 《给 Android 开发者的 RxJava 详解》 的脚步」,那都不重要了。 而且知道我的人也知晓,我不是扎根互联网的老程序员,对面试也是知之甚少,所以我不敢说这是「最好」的。 虽然这个系列已经不是「最好」的了,但我依然会花很多时间去完善他,感谢好友「兰柳学」的强势赞助。 为什么要写这个系列? 装逼从来都不是必要的,必要的是我们始终如一的想着装逼。 咳咳,讲点现实的,是因为今天面试被虐了。 一直以来我以为自己还算是个不错的 Android 开发工程师,GitHub 好像有较为欢迎的假象。还有一大批诸如 RxJava、Dagger2、Retrofit 在内的框架文章可以装装逼,但实际上大多数企业,尤其是互联网公司,根本就不会看重你娴熟运用框架的能力。 面试最后收到一句话:「 我们非常肯定你的开源分享能力和学习能力,我们也相信你能做好开发,但你的基础确实是太 low 了!」 其实从我的回答来说,我自己也觉得非常 low,用「舍本逐末」四个字来形容我再合适不过。 划重点!!! 为了防止一些类似我这样的 Android 开发工程师「严重偏科」,我决定出这么一个系列,我不知道这个系列多久可以出完,也许明天,也许三年