retrofit2

How can I debug my retrofit API call?

前提是你 提交于 2020-01-01 23:12:48
问题 I'm using retrofit to get some data from the Flickr api. The method I'm making the call in looks like this: public static List<String> getImageIds(int size) { Call<PhotosList> call = flickrService.getPhotos(apiKey, format, "1"); Log.d("TEMP_TAG", "photo url: " + call.request().url().toString()); photoIds = new ArrayList<String>(); call.enqueue(new Callback<PhotosList>(){ @Override public void onResponse(Call<PhotosList> call, Response<PhotosList> response) { Log.d("TEMP_TAG", "it's getting

How can I debug my retrofit API call?

故事扮演 提交于 2020-01-01 23:11:46
问题 I'm using retrofit to get some data from the Flickr api. The method I'm making the call in looks like this: public static List<String> getImageIds(int size) { Call<PhotosList> call = flickrService.getPhotos(apiKey, format, "1"); Log.d("TEMP_TAG", "photo url: " + call.request().url().toString()); photoIds = new ArrayList<String>(); call.enqueue(new Callback<PhotosList>(){ @Override public void onResponse(Call<PhotosList> call, Response<PhotosList> response) { Log.d("TEMP_TAG", "it's getting

HTTP/2 protocol not working with okhttp

Deadly 提交于 2020-01-01 08:26:07
问题 I am using Retrofit 1.9 with okhttp 2.4.0. So far we have SPDY protocol disabled on server side (I checked it by this ). And enabled protocol on server side is HTTP/2 (I checked it by this). So I was thinking that okhttp will try to make an api call using HTTP/2 (latest one protocol) but it's using HTTP/1.1 on android device 4.2.2 samsung S4 - D/Retrofit : OkHttp-Selected-Protocol: http/1.1 Someone told me that android device doesn't support SPDY until 5.0 (I don't have any proof), so that

HTTP/2 protocol not working with okhttp

孤者浪人 提交于 2020-01-01 08:26:02
问题 I am using Retrofit 1.9 with okhttp 2.4.0. So far we have SPDY protocol disabled on server side (I checked it by this ). And enabled protocol on server side is HTTP/2 (I checked it by this). So I was thinking that okhttp will try to make an api call using HTTP/2 (latest one protocol) but it's using HTTP/1.1 on android device 4.2.2 samsung S4 - D/Retrofit : OkHttp-Selected-Protocol: http/1.1 Someone told me that android device doesn't support SPDY until 5.0 (I don't have any proof), so that

How to handle error in Retrofit 2.0

老子叫甜甜 提交于 2020-01-01 08:17:24
问题 I want to handle error in Retrofit 2.0 Got e.g. code=404 and body=null , but errorBody() contains data in ErrorModel ( Boolean status and String info ). This is errorBody().content : [text=\n{"status":false,"info":"Provided email doesn't exist."}] . How can I get this data? Thank for helping me! This is my code for Retrofit request: ResetPasswordApi.Factory.getInstance().resetPassword(loginEditText.getText().toString()) .enqueue(new Callback<StatusInfoModel>() { @Override public void

Retrofit - android.os.NetworkOnMainThreadException

送分小仙女□ 提交于 2020-01-01 07:31:08
问题 I am using Retrofit 2 to get json and parse it to POJO. My purpose is getting one value of that object. compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4' My REST client: public interface MyClient { @GET("/part1/part2") Call<MyItem> getMyItem(@Query("param1") String param1, @Query("param2") String param2, @Query("param3") String param3); } Here I found great great tool to create service: public class ServiceGenerator { public

NoSuchMethodError Lcom/google/gson/Gson; upon retrofit response

微笑、不失礼 提交于 2020-01-01 06:54:29
问题 So, I've had my app published for nearly a year without seeing this issue, and now it shows up. Even right now, I don't have this issue with the debug version on my phone. I don't have any issues with any emulators opened from Android Studio. However nearly every emulator from the pre-launch reports in the Google Developer Console crashes with this NoSuchMethodError upon receiving Retrofit response. FATAL EXCEPTION: ControllerMessenger Process: xxxxxxx, PID: 25090 java.lang.NoSuchMethodError:

OkHttp SSLHandshakeException SSL handshake aborted Failure in SSL library, a protocol error

丶灬走出姿态 提交于 2020-01-01 04:57:18
问题 04-23 17:17:38.434 21599-21956/ D/NativeCrypto: ssl=0x0 NativeCrypto_SSL_interrupt 04-23 17:17:38.435 21599-21956/ D/OkHttp: <-- HTTP FAILED: javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x635d8808: Failure in SSL library, usually a protocol error error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:744 0x5e6c46fd:0x00000000) Android lower version devices (4.1 - 4.4) gives SSL

Upload file with Retrofit 2

…衆ロ難τιáo~ 提交于 2020-01-01 00:47:26
问题 I trying to do that a few days, and I really did everything.. Here is how request looks in Postman: I am sure, that all GET parameters were writing correctly. The problem in how I sending a file to upload, I suppose. Map<String, RequestBody> map = new HashMap<>(); File file = new File("/storage/emulated/0/ConstructSecure/d1940b05-76d1-4d98-b4b4-b04b8247c8cb.png"); RequestBody requestBody = RequestBody.create(MediaType.parse("image/png"), file); String fileName = file.getName(); map.put(

Retrofit2 Handle condition when status code 200 but json structure different than datamodel class

时间秒杀一切 提交于 2019-12-31 12:49:08
问题 I'm using Retrofit2 and RxJava2CallAdapterFactory . The API I consume returns status code always as 200 and for success and response JSON string the JSON structure is entirely different. Since the status code is always 200 the onResponse() method is called always. Hence, I'm not able to extract error msgs from the JSON in the error condition. Solution 1: I use ScalarsConverterFactory to get response String and manually use Gson to parse the response . How to get response as String using