retrofit

Android : Unable to upload multipart Image file using Retrofit 2.0.0 beta 2

痞子三分冷 提交于 2019-12-13 02:47:30
问题 Hi I am unable to upload an image using retrofit 2.0.0-beta2. It gives me "Image missing" error. Although I checked that file exist in system and also if I show in an Image view it is showing properly. URL on which it needs to be uploaded : http://mywebsite.com/signature/upload/ So my BASE_URL is = http://mywebsite.com/ my .gradle file has this : compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' compile 'com.squareup.okhttp:logging

Retrofit: Problems handling array or single object

ε祈祈猫儿з 提交于 2019-12-13 02:25:54
问题 I have been following other answers but there is a missing step that i cant find which is resulting in call being successful but the data not being parsed correctly because the first call i make returns a list of objects but only 1 object is returned which is all null MyModel.java public class MyModel { @SerializedName("url") private String mUrl; @SerializedName("name") private String mName; @SerializedName("description") private String mDescription; } MyModelDeserializer.java This just

How to use callback for multiple json array in retrofit?

一个人想着一个人 提交于 2019-12-13 02:07:19
问题 I am trying retrofit how to get data from below response { "schedule_students": [ { "id": "753", "sch_id": "153" }, { "id": "765", "sch_id": "153" } ], "s_students": [ { "id": "753", "s_id": "153" }, { "id": "765", "s_id": "153" } ], "schedu": [ { "id": "753", "ch_id": "153" }, { "id": "765", "ch_id": "153" } ], "delids": "no", "expdelids": "no", "lastsyncdate": "2015-06-01 10:33:19" } In my API response It's having multiple JSON array. How to retrieve all data from this response 回答1: Create

Using Retrofit with Imgur's API

混江龙づ霸主 提交于 2019-12-13 01:46:54
问题 I'm attempting to use the Retrofit library with Imgur's API with no success. I keep receiving 403 Permission Denied errors. The only authorization Imgur uses for what I'm attempting to do is through a header, which I (believe) I am doing correctly. My current code is the following: package me.rabrg.imgur; import me.rabrg.imgur.response.Image; import me.rabrg.imgur.service.ImageService; import retrofit.RequestInterceptor; import retrofit.RestAdapter; public class ImgurApi { private final

JsonArray as empty string parsing issue with retrofit

一世执手 提交于 2019-12-13 01:26:15
问题 I have a json in which 1 key is coming as jsonArray if it has data otherwise it is coming as empty string. It is giving error while parsing in gson with retrofit. "section": "Technology", "subsection": "", "title": "Depiction of Amazon Stirs a Debate About Work Culture", "abstract": "Details of working conditions at Amazon led to a response from employees, relatives and friends.", "url": "http://www.nytimes.com/2015/08/19/technology/amazon-workplace-reactions-comments.html", "byline": "By THE

Call another fragment page when clicking google map infowindow

不想你离开。 提交于 2019-12-13 00:59:40
问题 I am using retrofit to fetch data online.However I cannot find any solution to my problem. I want to call another fragment and display more of the details about the marker I clicked and pass those values to another fragment. Can someone please help me on this. Any help and solutions are well appreciated. MapFragment.jav RestAdapter adapter = new RestAdapter.Builder() .setEndpoint(getString(R.string.fine_dinings)) .build(); RestaurantPlacesApiInterface restaurantPlacesApiInterface = adapter

How to make a singleton for retrofit 2?

若如初见. 提交于 2019-12-12 19:22:05
问题 If there exists multiple retrofit call, how can i make a singleton of a retrofit, so that there won't be repeated codes within the class, thereby get rid of unnecessary codes. 回答1: Here's an example, but! Although this might be shiny and easy to use, singletons are evil. Try to avoid using them if possible. One way around it is by using dependency injection instead. Anyway. public class Api { private static Api instance = null; public static final String BASE_URL = "your_base_url"; // Keep

Yandex Maps return 403 Forbidden using retrofit

风格不统一 提交于 2019-12-12 19:14:36
问题 When I call this link https://geocode-maps.yandex.ru/1.x/?format=json&geocode=astana on my browser it works, but when I call it using retrofit It gives me 403 Forbidden My code is Retrofit retrofit = new Retrofit.Builder() .baseUrl(Settings.YANDEX_URL) .addConverterFactory(GsonConverterFactory.create()) .client(client) .build(); return retrofit.create(YandexService.class); public final static String YANDEX_URL = "https://geocode-maps.yandex.ru/1.x"; I call it using this @GET("/") Call

Retrofit - Different Response

穿精又带淫゛_ 提交于 2019-12-12 19:14:06
问题 I am consuming an API in Android using Retrofit. The success response looks different to the error/failure response. How can I therefore achieve this? I currently have something to this affect: Call<AuthenticateUserResponse> authenticateUser(String id); 回答1: You can extend your Responses with a base Response and check if there's an error or it's succeed. Here's an example base response bean below: public class BaseResponse { @SerializedName("ResponseCode") private int code; @SerializedName(

Retrofit2 Okhttp3 catch TimeOut

女生的网名这么多〃 提交于 2019-12-12 18:36:15
问题 I got a client like this: public enum RestClient { INSTANCE; private static final int CONNECTION_TIMEOUT = 10; private static final int READ_TIMEOUT = 30; private static final int WRITE_TIMEOUT = 30; private final Rest restClient; private RestClient() { restClient = new Retrofit.Builder() .baseUrl(App.getContext().getResources().getString(R.string.EP)) .addConverterFactory(JacksonConverterFactory.create()) .client(new okhttp3.OkHttpClient.Builder() .connectTimeout(CONNECTION_TIMEOUT, TimeUnit