retrofit2

Retrofit 2 not sending data when ProGuard is enabled

萝らか妹 提交于 2019-12-18 12:12:19
问题 I try to login my users using Retrofit 2. (Basically a GET to the login URL with a basic header) It works well but once I ProGuard it, the Header Authorization is not sent anymore. (See log outputs) Sample code : User Model : public interface UserService { @GET(GET_LOGIN) Observable<User> login(@Header("Authorization") String basic); } Login Activity : public void onClick(View v) { mRetrofit.create(UserService.class) .login(Credentials.basic(email, password)) .subscribeOn(Schedulers.io())

Is it possible to show progress bar when download via Retrofit 2 Asynchronous?

淺唱寂寞╮ 提交于 2019-12-18 11:30:28
问题 @Streaming @GET Call<ResponseBody> downloadSong(@Url String url); Above code is used to download file asynchronously using retrofit. I want get the progress of download, if there any possibility of pause/ resume please answer that too 回答1: At last I got my answer. For that we need to use rxjava along with retrofit. DownloadProgressListener.java public interface DownloadProgressListener { void update(long bytesRead, long contentLength, boolean done); } DownloadProgressResponseBody.java public

Retrofit @body with @multipart having Issue

人走茶凉 提交于 2019-12-18 11:15:23
问题 Image Multipart in class type object. case 1. (Which I had done) Service params: {"id":"1","name":"vishal","image/file":""} At that time my API of Retrofit @Multipart @POST("webservice") Call<SignUpResp> loadSignupMultipart(@Part("description") RequestBody description, @Part MultipartBody.Part file, @QueryMap HashMap<String, String> params); case 2. (Where I have Problem) with @Body class<UploadwithImage> { "methodName":"submitLevel1Part2Icon", "userid":"150", "headerData":{ "fiction":{ "icon

How to parse dynamic json in android with retrofit 2 using annotations

為{幸葍}努か 提交于 2019-12-18 09:34:13
问题 I have a JSON structure which I want to parse using retrofit 2 (@Expose). Below I have mentioned the JSON. Need help to parse it using dynamic annotations. { "status": 1, "message": "success", "data" : [ { "type": 1, "heading": "", "description": "", "created_on": 141123213, "author_id": 123, "author_name": "some name", "author_pic": "some_pic", "read_time": "3.1 min", "post_pic_url": "", "post_web_url": "", "isLiked": false, "isSaved": false, "totalLikes": 12 }, { "type": 2, "author_id": 123

Parameter does not have a match; SimpleXML

夙愿已清 提交于 2019-12-18 04:52:59
问题 I am using retrofit with the SimpleXMLConverterFactory . And I always get an ConstructorException: Parameter 'success' does not have a match in class ResponseInfo And I have no idea what could be wrong. The xml is very simple and i only want the string from the success node. xml: <?xml version="1.0" encoding="UTF-8"?> <response> <success>LoremIpsum</success> </response> ResponseInfo: @Root(strict = false, name = "response") data class ResponseInfo(@Element(required = false, name = "success)

How to get raw response and request using Retrofit 2.0

拟墨画扇 提交于 2019-12-18 04:35:22
问题 I am trying to get the raw response using Retrofit2.0.2. So far I tried to print the response using following line of code but it prints the address and not the exact response body. Log.i("RAW MESSAGE",response.body().toString()); compile 'com.squareup.retrofit2:retrofit:2.0.2' Retrofit retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); GitApi gitApi = retrofit.create(GitApi.class); Call<Addresses> call = gitApi.getFeed(user);

multiple api request using retrofit and rx java

雨燕双飞 提交于 2019-12-17 19:03:31
问题 I am new to android and I have a scenario where I want to get get data from multiple api. Let suppose api_a , api_b , api_c , api_d . These api are independent of each other but I want to show data from these api in a mix Recycler View ( horizontal and vertical ). So I want to make these api call in such a manner so that I can get every api data at a time so that i can display in recycler view. I already using retrofit 2 but for that I had to chain them one by one which is very lengthy and I

Retrofit 2 can't upload a file with two additional separate string parameters

岁酱吖の 提交于 2019-12-17 18:52:03
问题 Read edit at bottom of the question for possible alternative solution until the solution is found . This is a successful post file with two parameters using POSTMan. I am trying to do the same with retrofit but receive BadRequest. PostMan Settings: Chrome Network Post Details: Now here is how I am doing this in Android but failing: Retrofit Service Interface: @Multipart @POST("jobDocuments/upload") Call<ResponseBody> upload(@Part("file") MultipartBody.Part file,@Part("folder") MultipartBody

How to make multiple request and wait until data is come from all the requests in retrofit 2.0 - android

徘徊边缘 提交于 2019-12-17 17:36:55
问题 current code: Retrofit retrofit = new Retrofit.Builder() .baseUrl(Constant.BASEURL) .addConverterFactory(GsonConverterFactory.create()) .build(); APIService service = retrofit.create(APIService.class); Call<ResponseWrap> call = service.getNewsData(); call.enqueue(new Callback<ResponseWrap>() { @Override public void onResponse(Call<ResponseWrap> call1, Response<ResponseWrap> response) { if (response.isSuccess()) { ResponseWrap finalRes = response.body(); for(int i=0; i<finalRes.getResponse()

Sending JSON in POST request with Retrofit2

为君一笑 提交于 2019-12-17 16:28:32
问题 I'm using Retrofit to integrate my Web services and I do not understand how to send a JSON object to the server using a POST request. I'm currently stuck, here is my code: Activity:- @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Retrofit retrofit = new Retrofit.Builder().baseUrl(url). addConverterFactory(GsonConverterFactory.create()).build(); PostInterface service = retrofit.create(PostInterface