retrofit

Moshi cannot parse nullable

一曲冷凌霜 提交于 2021-01-28 11:30:21
问题 Hello) Hope you can help me. Using kotlin (Retrofit2 + moshi) i getting data from "https://api.spacexdata.com/v3/launches" and parsing it. All is going fine (i getting attributes like: flight_number, mission_name), but some attributes have "null", like "mission_patch" - there are 111 objects. 109 of them have data at "mission_patch", 2 objects dont have it ("mission_patch":null). My problem: moshi cannot parse correctly attribute which contains null. if i using: data class SpaceXProperty( val

Trying to get post from JsonPlaceHolder by retrofit, but response isn't showing methods

本小妞迷上赌 提交于 2021-01-28 11:01:45
问题 I'm new in retrofit, I'm trying to get single post from jsonplaceholder website, the problem is that I can't find getTitle, getBody, getId, and getUserId in onresponse method in callback. I typed (response.body.) , but getter methods doesn't appear. MainActivity public class MainActivity extends AppCompatActivity { TextView tvText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tvText=findViewById(R.id

What is the role of 'com.google.code.gson:gson:2.6.1' dependency in retrofit 2 when it has its own gson converter?

僤鯓⒐⒋嵵緔 提交于 2021-01-28 09:12:05
问题 // Retrofit compile 'com.squareup.retrofit2:retrofit:2.1.0' // JSON Parsing compile 'com.google.code.gson:gson:2.6.1' compile 'com.squareup.retrofit2:converter-gson:2.1.0' My question is regarding the second and third dependency added. I do understand it is related to JSON conversion. If the third dependency is added,would the second dependency still be needed? I have seen them both being added on several examples. For e.g: https://www.androidhive.info/2016/05/android-working-with-retrofit

SocketException unsubscribing request without onError

孤人 提交于 2021-01-28 03:11:51
问题 I'm trying to make a request using RxJava and Retrofit(2.3). I'm expecting that in case of any error I can retry or show a message to the client. However, I notice that sometimes I have a SocketException which results in not calling onError, apparently the subscriber of the request just unsubscribes without calling anything else (not onComplete neither onError). Anyone knows why this is happening and how can I solve this in a generic way (without simply doing onUnsubscribe() and checking if

How to send array of objects in retrofit multipart request

倾然丶 夕夏残阳落幕 提交于 2021-01-27 13:42:13
问题 I want to send array objects with multipart data. I tried many ways but it is not working. My issue with the contributor parameter. Server says. contributor.0.id is required & contributor.0.role is required and so on for remaining items in the list. Server reads that there is a contributor array and it has items but he can't extract it for some reason. Any help please? @Multipart @POST("project/create") fun createProject( @Header("Authorization") token: String, @Part("title") title: String,

Multiple enqueue in retrofit causing out of memory error?

点点圈 提交于 2021-01-27 13:01:39
问题 Am doing my project using retrofit2. When my Call goes on failure i repeat same call again.Repeation of this call made my app to force close. When i look on log i got error log, which is given below. I felt this is caused by multiple enqueue to same Call. So i did that before enqueus i called cancel. But its not working. getting same force close. FATAL EXCEPTION: main Process: com.SocialMob, PID: 27846 java.lang.OutOfMemoryError: pthread_create (stack size 16384 bytes) failed: Try again at

Retrofit: how fix “only one http method is allowed. found: get and get”?

◇◆丶佛笑我妖孽 提交于 2021-01-27 05:23:28
问题 I have that structure for request. Request getTransportByStation work perfectly. But I get exception java.lang.IllegalArgumentException: TransportWebService.getTransportByRoute: Only one HTTP method is allowed. Found: GET and GET. I found solution only for POST and POST. interface TransportWebService { @GET(QUERY_CATEGORY_TRANSPORT + "GetTransportByNextStation/{station}") Observable<ResponseRouteList> getTransportByStation( @Path("city") String city, @Path("station") String station, @Query(

Retrofit: how fix “only one http method is allowed. found: get and get”?

自闭症网瘾萝莉.ら 提交于 2021-01-27 05:22:20
问题 I have that structure for request. Request getTransportByStation work perfectly. But I get exception java.lang.IllegalArgumentException: TransportWebService.getTransportByRoute: Only one HTTP method is allowed. Found: GET and GET. I found solution only for POST and POST. interface TransportWebService { @GET(QUERY_CATEGORY_TRANSPORT + "GetTransportByNextStation/{station}") Observable<ResponseRouteList> getTransportByStation( @Path("city") String city, @Path("station") String station, @Query(

Transfer Encoding chunked with okhttp only delivers full result

喜你入骨 提交于 2021-01-27 04:42:12
问题 I am trying to get some insights on a chunked endpoint and therefore planned to print what the server sends me chunk by chunk. I failed to do so so I wrote a test to see if OkHttp/Retrofit are working as I expect it. The following test should deliver some chunks to the console but all I get is the full response. I am a bit lost what I am missing to even make the MockWebServer of OkHttp3 sending me chunks. I found this retrofit issue entry but the answer is a bit ambiguous for me: Chunked

Retrofit 2 disable encoding for post parameters

淺唱寂寞╮ 提交于 2021-01-27 04:11:48
问题 I am beginner in retrofit... I need send POST request with simple parameters name : value login[name] : some-name login[pw] : some-pw date : 2017-08-28T12:12:12+0200 so, I tried @FormUrlEncoded @POST(urlLogin) Call<Login> signIn(@Field("login[name]") String name, @Field("login[pw]") String pw, @Field("date") String date); that send to the server: login%5Bname%5D : some-name login%5Bpw%5D : some-pw date : 2017-08-28T21%3A11%3A57%2B0200 next @FormUrlEncoded @POST(urlLogin) Call<Login> signIn(