retrofit2

Retrofit2 error java.io.EOFException: End of input at line 1 column 1

社会主义新天地 提交于 2019-12-30 03:38:07
问题 I called PATCH web service using Retrofit2 but onResponse is not called and the onFailure is called Despite of the operation of the service is succeeded on the server side perfectly And whenever,I tried to use fiddler to check the service its working , i found the problem is that serializing the coming response of the service and when using fiddler i found that no content of the JSON response so the Retrofit service assumed that its failed because there is no content and it cannot serialize

How to Post JSON array using Retrofit 2

非 Y 不嫁゛ 提交于 2019-12-29 07:41:51
问题 I need to post an JSON object using Retrofit 2. My JSON object is { "logTime" : "", "datas" : [ { "dat1": "1", " dat2": "", " dat3": "", " dat4": "", " dat5": "" }, { "dat1": "1", " dat2": "", " dat3": "", " dat4": "", " dat5": "" } ]} I have tried using following code: API Services @FormUrlEncoded @Headers({ "Content-Type: application/json", "x-access-token: eyJhbGciOiJIU" }) @POST("/api/employee/checkin") Call<String> CHECKIN(@Body String data); Activity Class JSONStringer jsonStringer =

How to Post JSON array using Retrofit 2

那年仲夏 提交于 2019-12-29 07:41:29
问题 I need to post an JSON object using Retrofit 2. My JSON object is { "logTime" : "", "datas" : [ { "dat1": "1", " dat2": "", " dat3": "", " dat4": "", " dat5": "" }, { "dat1": "1", " dat2": "", " dat3": "", " dat4": "", " dat5": "" } ]} I have tried using following code: API Services @FormUrlEncoded @Headers({ "Content-Type: application/json", "x-access-token: eyJhbGciOiJIU" }) @POST("/api/employee/checkin") Call<String> CHECKIN(@Body String data); Activity Class JSONStringer jsonStringer =

How to get string response from Retrofit2?

谁说我不能喝 提交于 2019-12-28 05:43:26
问题 I am doing android, looking for a way to do a super basic http GET/POST request. I keep getting an error: java.lang.IllegalArgumentException: Unable to create converter for class java.lang.String Webservice: public interface WebService { @GET("/projects") Call<String> jquery(); } then in my java: Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://jquery.org") // .addConverterFactory(GsonConverterFactory.create()) .build(); WebService service = retrofit.create(WebService.class); Call

Retrofit Uploading multiple images to a single key

随声附和 提交于 2019-12-28 01:48:11
问题 I am using Retrofit to upload images to my server. Here I need to upload multiple images for a single key. I have tried with Postman web client it is working well. Here is a screenshot. Here are the key value pairs for the request. SurveyImage : [file1,file2,file3]; PropertyImage : file DRA : jsonBody I tried to do the same with Retrofit. but the images are not uploading to the server.Here is my code. WebServicesAPI.java public interface WebServicesAPI { @Multipart @POST(WebServices.UPLOAD

Retrofit 2 OkHttpClient caching not working

妖精的绣舞 提交于 2019-12-25 18:53:52
问题 So here's the problem, I'm trying to implement caching for my app and I followed this tutorial Android: Cache network requests for offline access with Retrofit2 and OkHTTP3 to do it. Sadly, cached responses are not showing up when there is no internet connection, instead the Toast.makeText(getContext(), getContext().getResources().getString(R.string.error_failed_to_load_posts), Toast.LENGTH_SHORT).show(); gets executed. So can anyone tell me what I am doing wrong? Or guide me to get an answer

How can I get token with Retrofit2?

扶醉桌前 提交于 2019-12-25 18:48:31
问题 I have a web service link for token login. But in this link, there is no "/" at the end of link. And android studio make error called baseUrl must end in / . When I put / it don't get token and say token is not truth :( because the link is not correct in my think. I use retrofit2 library. Please help me to solve it. MainActivity.java public class MainActivity extends AppCompatActivity { Retrofit.Builder builder = new Retrofit.Builder() .baseUrl("http://website.net/token") .addConverterFactory

Response in 202 STATUS in Retrofit2.0

我的梦境 提交于 2019-12-25 18:34:30
问题 i want to convert the Response in to JSON and show it to the User .I was able to display 200 response but in 202,i am failed. { Log.d(TAG, "RESPONSE CODE" + response.code()); if (response.code() == 200) { Gson gson = new Gson(); SuccessResponse signupResponse = response.body(); String sSignupResponse = gson.toJson(signUpResponse, SuccessResponse.class); try { } catch (JSONException e) { e.printStackTrace(); } } else if (response.code() == 202) { Log.d(TAG,"RESPONSE CODE IS "+"202 RIGHT");

Expected BEGIN_ARRAY but was BEGIN_OBJECT with Gson and Retrofit

南笙酒味 提交于 2019-12-25 18:14:28
问题 My app try to consume an API using Retrofit and Gson . My request is to https://nahuatiliztli.herokuapp.com/laws.json and it returns back: [{"id":1,"title":"Constitución Política de los Estados Unidos Mexicanos","url":"http://www.diputados.gob.mx/LeyesBiblio/pdf/1_29ene16.pdf","created_at":"2016-07-10T02:36:00.641Z","updated_at":"2016-07-10T02:36:00.641Z"}] My code is structured as follow… My model is Law class: public class Law { @SerializedName("id") private Integer mId; @SerializedName(

My ProgressDialog is Not Disappearing

无人久伴 提交于 2019-12-25 17:52:11
问题 I am working on a project in android to upload a file to server using file chooser But there is a problem, when i am Uploading more than 500 kB file. The file is uploaded but My Progress Dialog is not disappearing and if i uploaded file 100 KB it's uploaded to server and i got a message file uploaded successfully. But I'm not able to get server response if i uploaded more than 500 kB file. Please Help me. Thank You. It's my UploadFile() Methods private void uploadFile() { dialog =