Questions tagged [retrofit]

Retrofit is a type-safe REST client for Android and Java by Square, Inc.

1
vote
0answers
9 views

Zip network requests via Kotlin Coroutine Flow

I have a code which zips two network requests via RxJava: Single.zip(repository.requestDate(), repository.requestTime()) { date, time -> Result(date, time) } it means that repository....
-3
votes
0answers
14 views

How can i create a json object and send it to the api using retrofit library in android [on hold]

I want to send username, password, email, lastname and firstname to the API in the form of JSON object. I am not able to perform this.
1
vote
1answer
26 views

Saving image on the server with URL with android app ERROR End of input error at line 1 column 1 path $

I have an android app where the user selects an image from the gallery and then when he saves it, the image is saved in the UPLOADS folder on my server and in the MySQL table the image url is saved. ...
0
votes
0answers
20 views

Retrofit Response Body is Empty

i am using retrofit and rest api and getting empty response body in retrofit.please help me to solve this issue. public void signUp(String username,String password,String name,String type,String ...
0
votes
2answers
29 views

I receive a null response when I pass an object with retrofit

I receive a null response when I passed an object with a Retrofit2. I get the request with the URL, but seeing the content this is null. I do not know why... public interface WeatherAPI { @GET("...
0
votes
2answers
44 views

What is the best way to post parameter into APIs?

Like some of the senior developers of my company are saying I am posting data in the wrong way. I want to know which way is best. Basically, we send data in Body Parameter like:- // In Retrofit or ...
3
votes
1answer
54 views

How should I use Dagger2 with Retrofit?

I'm working in a project and I need to inject Retrofit object with Dagger 2. I search info but I only have been able to do a few steps and now I don't know how to continue: My component: @Singleton ...
0
votes
1answer
35 views

OkHttp Interceptor chain broken when getting token

I have an OkHttp Interceptor which should ask for a token when the request is getting a 401 HTTP error. Now, the request to login service is done but then the chain is broken and the original request ...
1
vote
1answer
26 views

Upload RecyclerView To Php Server Android

I am developing E-Store App I want to upload the cart data which i am getting from php server to recycler view. I want to upload the whole recycler view to the database using Retrofit 2.0 and rest API....
0
votes
4answers
36 views

Can't receive value from ListView, while using setOnItemClickListener interface

I'd want to take have a movie title from ListView by click on it. The data what I'm getting, is from api, served by retrofit. For now, I'm tried to use this interface listView.setOnItemClickListener(...
0
votes
0answers
45 views

How to do check if ArrayList object [duplicate]

I am making a retrofit POST request using Paging library. When the first page is loaded the next page is automatically called. But when it comes to the last page (assume page 5), it requests for ...
2
votes
1answer
70 views

How to stall an API request until user is online using Retrofit?

I'm developing an application. I'm sending an API request with retrofit. In cases where there is no internet, I want to store this request and send it again as soon as the internet is connected. How ...
1
vote
1answer
26 views

Getting 401 using themoviedb, and retrofit

so I'd wanted to make API call with a dynamic request, but for first, I'd created the "raw" call, hardcoded. So, this address in a web browser works fine https://api.themoviedb.org/3/discover/movie?...
0
votes
0answers
20 views

Retrofit Android GET Failure

Couldn't get any data in return onResponse, the result skipped to onFailure. It works on my other application, data is return and displayed successfully, but the same thing failed on this ...
0
votes
0answers
8 views

Play audio file from API seekbar live change with file progress android studio

I want to play an audio file from my own database through API. I can play the file but can't update the progress bar with the file position change. How can I solve it? I can play and pause the audio ...
-1
votes
0answers
12 views

Retrofit onFailure with API > 23 [duplicate]

I can't solve the problem. Same code gives onResponse with API 21, but onFailure with API 28. Any ideas? public class MainActivity extends AppCompatActivity { ListView listView; @Override ...
0
votes
1answer
17 views

Retrofit - invalid parameters in call

I've just get the code from response, and it says, that my request parameters are wrong, what should my api call look like then? Here's the hardcoded api call from documenatation https://api....
0
votes
0answers
28 views

upload image with progress bar retrofit android

I want to upload image with progress like this tutorial it work fine but i want to get response from call , he use retrofit call inside service to upload but response only double progress i want to ...
0
votes
0answers
47 views

I do not know what to send to the server

By typing this url on browser i can get json answer. But I don't know how to create this request on Android by using retrofit urladdress/new/history/start[name]=Shagabutdinova &start[lat]=43....
0
votes
2answers
45 views

ANDROID: MVVM + Retrofit: How and where shall I retrieve JSON Object List from JSON object array?

I have set up everything for calls and I am getting list with 0 size. After some research, I realized that I was trying to retrieve JSON objects, meanwhile the root of my response.body is a JSON array....
0
votes
3answers
35 views

Can't display data in ListView using Retrofit

I 've problem with display data in ListView. I get data from Retrofit response, but my activity, which should display this data, is just beeing blank, all the time. I am sure, that I've receiving data,...
0
votes
2answers
29 views

is it possible to mock a retrofit Deferred<Response<T>> in Kotlin?

I am wondering if I can do this mock Deferred<Response<Void>> I am new at Kotlin and at mock but I have unsuccessfully made it. So far I have done this: I have a client interface: ...
-2
votes
0answers
46 views

Nested object loop

I've got a problem about how to realize this API in my app. [ { "items": [ { "id": 1, "itemID": 2, "itemName": "Name", "itemPrice": 99, "quantity": 2, "userID": 20 }, ...
-1
votes
2answers
65 views

How to get raw json response of Retrofit in Kotlin?

I am new to Kotlin and Retrofit. I want to call a base URL through Retrofit and print the raw JSON response. What would be the simplest minimal configuration? Let's say, base url = "https://devapis....
0
votes
1answer
44 views

How can I use coroutines with my api call? MVP pattern

I'm pretty new on coroutines and I'm wondering what I'm doing wrong... I have a service that is returning an Object @GET("list/{id}") suspend fun getId(@Path("id") id: Long): Response<...
0
votes
1answer
12 views

Retrofit: is it possible to map “Literal Object” used as Map to a POJO?

The only way I found to serialize "non 0-to-n" lists (like the "non 0-to-n" arrays you can use in PHP) into JSON format, was making something like this: { "one": 1, "two": 2, "three": 3 } ......
1
vote
1answer
31 views

Retrofit is stripping trailing slash in url

I have a url like such: https://www.dummy.com/api/v1/ public interface DummyService { @POST("path/") Observable<Response<Void>> postToDummy(@Body String someBody); } I want to ...
0
votes
1answer
49 views

Download list of files with retrofit and rxJava

I´m trying to download a list of files from an api with retrofit and rxjava i read a lot but i can't figurated how retrofit and rxjava work together, and im not sure what kind of thread must use on ...
0
votes
0answers
17 views

How to send this image using form-data using retrofit2 [closed]

https://imgur.com/a/6f2IVgV So i've been trying in postman to upload an image like the screenshot above and it works. But i can't do it in android using retrofit. How can i do it ? Here's what i've ...
0
votes
0answers
16 views

How to handle 'internet connection gone' during download process via retrofit

Simple and clear issue: I am downloading a file via retrofit (using request and response mechanism + @streaming annotation). everything goes FINE!!!! PROBLEM is how can i handle situation that "...
0
votes
0answers
17 views

Sign Http Request with Retrofit2

I'm trying to download a resource from a service using Retrofit2 following their guide. The code is in Kotlin and the service uses OAuth 1.0a. interface DownloadManager { companion object { ...
0
votes
3answers
36 views

Retrofit always response to onFailure

I'm setting up a new android project and using retrofit, my retrofit function work correctly in emulator (NOX) and postman but when I try build my app in mobile device, retrofit always get into ...
1
vote
1answer
38 views

How to parse inner json string as nested class using retrofit

I have used retrofit with nested classes before, but the current api I'm tring to use has such a structure: Request body: { "Id" : "a2", "messageCode" : 1, "bigNestedClass" : "{\"field1\":...
2
votes
3answers
64 views

Didn't get any data from Retrofit

i have a problem with Retrofit call. I'd wanted to get some data, just for testing purposes, to see if anything come, but as you can see, nothing comes. I've getting data like 0, 0.0, null. Json ...
0
votes
3answers
33 views

Get Json Array in Post Retrofit

I have a problem when I want to retrieve an array from a post response this is my post { "user_email": "[email protected]", "user_password": "12345" } and this is my post response , I want get ...
0
votes
3answers
57 views

OkHttp3 Interceptor add fields to request body

As my APIs requests all contains some json fields in common, I would like to add those fields inside an interceptor, but I'm struggling to modify the OkHttp3 RequestBody inside the interceptor Here ...
-1
votes
0answers
23 views

Loading entities from database and server API by using RxJava

I've found this great article: “Loading entities from database and server API by using RxJava” by Hadi Lashkari Ghouchani https://link.medium.com/Fc9qvbtEfX If my business rule was only "load from ...
0
votes
1answer
18 views

Getting API Response header as POJO using retrofit in android

I am using Retrofit for API requests. In my application i get data as response in both header and body. As we all know "body" we can convert as POJO by using some libraries using Gson or Jackson etc, ...
0
votes
1answer
30 views

Abstraction Library for Retrofit

I am writing a layer of abstraction on top of Retrofit Network Library so that we can change the Retrofit anytime without much impact on application code. And we typically write an interface and ...
0
votes
0answers
14 views

Unable to aces files from a File android Uploader Service

I am trying to upload files to a server from a Android service.The files are stored in a directory and the path to the directory is passed through the Intent while starting the service. For upload i ...
0
votes
0answers
34 views

How to use execute in Retrofit

I don't know how to use execute in Retrofit. I used call.enqueue in retrofit for getting address from openstreetmap. but I got error for using it in main thread. I should use execute in AsyncTask ...
0
votes
3answers
72 views

How do I parse a field from a deep nested json object using Gson and retrofit in android?

I have a unique situation where I have to get certain times from a json's deeply nested object. It's a little complex, I couldn't find a solution so looking for ideas and ways to tackle this I have a ...
0
votes
2answers
38 views

How to build two build android variant for fetching two Different URL using Retrofit?

I am developing an android application for fetching two different Rest API for two different Build Variant sharing the same DataSource. I am using product flavor for a build variant. But I don't know ...
-1
votes
2answers
35 views

Retrofit2 can't retrieve monthly currency data from API

I'm trying to make an app, which will show user specifed by him monthly currencies rates. For now, just for testing purposes, I'd like to get monthly USD rates. But I'm already tried to do that in a ...
4
votes
1answer
106 views

How to create a call adapter for suspending functions in Retrofit?

I need to create a retrofit call adapter which can handle such network calls: @GET("user") suspend fun getUser(): MyResponseWrapper<User> I want it to work with Kotlin Coroutines without using ...
-1
votes
2answers
30 views

Retrofit 2 error - Expected a string but was BEGIN_OBJECT

I've tried to get from currency api response which should display for me the monthly values of specifed by user currencies, but I've got a problem with making correct retrofit call. Where's can be ...
0
votes
3answers
35 views

Data model for nested object in Retrofit/GSON

I'm using a remote weather API and got the following data from it. I'm making calls with Retrofit and I use GSON. {"coord":{"lon":127.08,"lat":37.51},"weather":[{"id":701,"main":"Mist","description":"...
-1
votes
3answers
28 views

Android data model with only the fields that I need

If I make use of Retrofit and a data model. Does the data model need to have all the fields that the API returns? I only need some fields.
0
votes
2answers
20 views

Retrofit server response is getting 307 in android

Step1: Need to give input to server.as below image step2: get response from server ,as below image. ![enter image description here][2] step3: MainActivity.java @RequiresApi(api = Build....
0
votes
0answers
24 views

Retrofit: lowercase headers

I would like to upload a file with Retrofit. But I have to send my request with lowercase headers. I tried to override headers but without any effect: @Multipart @PUT fun uploadFile( @Url url: ...