Questions tagged [retrofit]
Retrofit is a type-safe REST client for Android and Java by Square, Inc.
8,541
questions
0
votes
0
answers
8
views
Implementing streaming response for OpenAI's GPT 3.5 Turbo API in Android using Retrofit
How can I implement streaming response for OpenAI's GPT 3.5 Turbo API in my Android chatbot app? Currently, I am using Retrofit to get the API response, but it takes around 15 to 20 seconds. I would ...
0
votes
0
answers
10
views
Handling Return Code 500 in .NET Web Services using Retrofit
I have been working on a .NET web service that I developed and currently have it hosted on a local Windows server. In order to access it, I substituted "localhost" with the corresponding IP ...
0
votes
0
answers
12
views
POJO class without hardcoded value in Android Studio Java
Is it possible to parse JSON response from an API without hardcoding the Object name? I want to parse this JSON but the value of random_number is always changing so I am not able to hardcode it in my ...
0
votes
0
answers
4
views
i can't get object in fileds, how do i get i to make a message notif in android
objects in fields can change their data, I want to retrieve data in the field object to be used as a message. i use RxJava and retrofit.
{
"status": 422,
"success": false,
...
0
votes
0
answers
15
views
MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
When I use retrofit using https://api.github.com/users it works without problems but when I switch the information where it matches the values I have the following error appears, com.google.gson....
18
votes
3
answers
11k
views
How to pass custom enum in @Query via Retrofit?
I have a simple enum:
public enum Season {
@SerializedName("0")
AUTUMN,
@SerializedName("1")
SPRING;
}
Starting some version, GSON became able to parse such enums. To make sure, I ...
4
votes
3
answers
1k
views
Ignore unregistered subtypes in RuntimeTypeAdapterFactory
We have a Retrofit API using GSON as the converter, and it makes a call for a list of cards to display to the user. A card follows this format:
[
{
"cardType": "user",
"data": {}
...
-2
votes
0
answers
34
views
What to use networking libs for building server code using Kotlin? [closed]
I am a C++ Windows desktop only application coder with no experience in Java or networking, so please forgive if I am asking something obvious.
To build a server that works with Android and iOS phones,...
0
votes
1
answer
37
views
Gson serializer for ZonedDateTime from java.time [duplicate]
I use Retrofit2 with Gson. I wrote a custom serializer for ZonedDateTime but it's not working. When I try to debug sending requests to the server, I see that the bugger does not enter the serialize ...
0
votes
0
answers
10
views
How can I send the data I get from the api with workmanager as a notification?
My Worker Class
class NotificationWorker(
private val context: Context,
params: WorkerParameters,
) : CoroutineWorker(context, params) {
private val viewModel: QuoteSunshineViewModel by ...
0
votes
0
answers
44
views
javax.net.ssl.SSLHandshakeException: Handshake failed, javax.net.ssl.SSLHandshakeException
[javax.net.ssl.SSLHandshakeException: Handshake failed, javax.net.ssl.SSLHandshakeException: Handshake failed, java.net.SocketTimeoutException: failed to connect to website.com/2a06:98c1:3120::3 (port ...
2
votes
1
answer
172
views
How to reinit singleton in Hilt (Android)?
I have Hilt DI framework in my Android project. Also I have retrofit, and ApiNetworkModule for getting singleton retrofit object:
@Module
@InstallIn(SingletonComponent.class)
public class ...
0
votes
1
answer
23
views
How can I generate the API link dynamically with multiple queries in Kotlin using Retrofit 2?
This is my interface class
interface CalorieCalculationInterface {
@GET("/macrocalculator")
fun getData(@Query("age") age: Int?, @Query("gender") gender : String?,...
19
votes
7
answers
5k
views
failure : retrofit.RetrofitError: 307 Temporary Redirect?
I am using the library com.squareup.retrofit:retrofit:1.9.0, in order to send data to my server from my android Application.
In fact,when I want to send a request to the server, I found this error:
...
0
votes
0
answers
13
views
How to unit test Retrofit server response?
I want to view(print to so) the response from the server in JUnit for the following Retrofit api:
@GET("search/photos")
suspend fun searchPhotos(
@Query("query") query: String,
...
0
votes
2
answers
846
views
How to add Bearer token Authorization in Retrofit Flutter
How to add Bearer token Authorization in Retrofit Flutter.
Here is Retrofit Service
@RestApi(baseUrl: "https://***.****.xyz/api/")
abstract class ApiService{
factory ApiService(Dio dio) =&...
3
votes
2
answers
3k
views
How to upload Audio (Mp3) to Server Using Retrofit2 Android
How to upload an audio file by retrofit?
I brought some of the classes and code I wrote, but I did not respond to these codes
Interface:
@Multipart
@POST("comments")
Call<Wallet> ...
1
vote
1
answer
32
views
Jetpack Compose LazyColumn & Retrofit: Strategy for providing data to a details-view
When I got a list with items (articles), which data is loaded from a web-API as JSON, using Retrofit.
I populate a LazyColumn with some of the loaded data. From a single article one can navigate into ...
0
votes
1
answer
112
views
Philips Hue Android app - common name validation (with Retrofit)
Having trouble with API calls to Hue. I'm using Retrofit, and calling their v1 API.
I think the problem is "common name validation", from their docs:
"The other part of the certificate ...
0
votes
0
answers
35
views
How to fix error 'The request is missing a valid API key' in Kotlin Retrofit for Google Translation API?
I use retrofit and Rapid api to use Google translation api but i have an error:
{
"code" : 403,
"errors" : [{
"domain" : "global",
"...
0
votes
0
answers
17
views
Rx2AndroidNetworking that created by amitshekhar not work with android version 31 and above
I get this error message when making a request by Rx2AndroidNetworking.
java.lang.IllegalArgumentException: com.gomini.gominipassenger: Targeting S+ (version 31 and above) requires that one of ...
120
votes
10
answers
376k
views
Call another rest api from my server in Spring-Boot
I want to call another web-api from my backend on a specific request of user. For example, I want to call Google FCM send message api to send a message to a specific user on an event.
Does Retrofit ...
156
votes
5
answers
72k
views
why use Retrofit when we have OkHttp
With OkHttp we can make HTTP request then get response from server:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.build();
Response response = ...
0
votes
1
answer
284
views
Android emulator not connecting to localhost via 10.0.2.2
My local API setup is running in localhost:3000on my Windows 10. I am using Retrofit to connect with APIs. I used http://10.0.2.2:3000 for connecting Android emulator to Window's localhost. It was ...
0
votes
1
answer
26
views
How to solve JsonIOException problem when i have http-request using retrofit2
My project was running perfectly but suddenly show this error when i request a list from server by retrofit using GsonConverter :
FATAL EXCEPTION: main
com.google.gson.JsonIOException: Interfaces can'...
0
votes
0
answers
9
views
Resilience4j 2 and retrofit - what happened to the resilience4j-retrofit module?
In Resilience4j 2 the retrofit module got removed (still present as reslience4j-retrofit). Does anyone know if it got replaced by an external module? Are users of retrofit supposed to write and ...
0
votes
0
answers
8
views
Anonymous user enter the app without token and anonymous user want to login then i need to send token
what I do in this=> if DO_IT_LATER value ==1 then i am not sending token else sending token
but the problem is that I entered the application with the anonymous user now DO_IT_LATER value is 1 and ...
-1
votes
2
answers
39
views
How to map from DTO to domain when have nullable field in API and don't need it on domain model
I get a complex model from server with Retrofit. I simplified it to make it more obvious.
Two fields are obligatory, but bottomSheet is optional. The problem is that I have to make all the fields of ...
0
votes
1
answer
28
views
Hilt: error when provide Retrofit service
I am trying to integrate Hilt into my Android app. All was fine until I add Hilt to provide Retrofit service with weird error:
Cause: not a valid name: default
Full stacktrace:
* Exception is:
org....
15
votes
3
answers
18k
views
How to use GraphQL with Retrofit on Android?
I'm new to GraphQL but I have been using Retrofit for a while now and its easy to use and fast. GraphQL is much different than rest apis in terms of how you pass data. There really are not too many ...
178
votes
17
answers
137k
views
Unable to create converter for my class in Android Retrofit library
Im migrating from using Volley to Retrofit, I already have gson class that I used before for converting JSONObject reponse to a object that implements gson annotations. When I'm trying to make http ...
1
vote
5
answers
13k
views
Retrofit 2.0.2 get error string body
I use Retrofit 2.0.2 and I can't get error body json and convert it.
Here my code:
public RestClient() {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
....
0
votes
1
answer
40
views
Token refreshing with Retrofit and Interceptor for multiple requests in Android
How to handle token refresh for multiple requests in Interceptor?
I'm implementing token refresh functionality in my Android app using an AuthInterceptor in Retrofit. The code provided works well for ...
1
vote
0
answers
27
views
Retrofit returning NULL Response
Here is my code, what am I doing wrong?
DeviceFetcher.java
public class DeviceFetcher extends AppCompatActivity {
private static final String BASE_URL = "https://base-url/";
...
1
vote
1
answer
23
views
Why is it not possible to transfer the user token to the API django rest framework?
There is an API based on the django rest framework, which outputs an order model in which there is a user token, order date, products, and price.
{
"userToken": "...
367
votes
22
answers
247k
views
Logging with Retrofit 2
I'm trying to get the exact JSON that is being sent in the request. Here is my code:
OkHttpClient client = new OkHttpClient();
client.interceptors().add(new Interceptor(){
@Override public com....
0
votes
1
answer
44
views
java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
This is the interceptor code i cant figure out where to call the response.close() on the logCat it states that the error appears on the "response = chain.proceed(request). Where do i place the ...
0
votes
1
answer
38
views
What library to use to connect to rest api? [closed]
I need to connect to external REST API. Now i am using ktor lib and Coroutine but I'm wondering if there is a better library for this. I'm new in kotlin, so I need help to choose.
OkHttp, Retrofit or ...
0
votes
0
answers
7
views
Android : How to use compression for APIs to improve performance on slow internet connection?
I am developing an Android app that uses Retrofit for networking. Some of the APIs that I use return large JSON responses(1 KB) that might take a long time to download on slow internet connection. I ...
0
votes
0
answers
32
views
How to read data from api using retrofit in Android Kotlin
Below is my json and I am trying to read data under the "productsDetalys" using retrofit.
I can read the data like "orders_id", "customers_id" etc but "...
4
votes
2
answers
950
views
Queuing/saving retrofit requests and send them later when there is poor/no internet connection
I have my android application which is not build to work offline, so it is reliant on network connection/data.
App makes a lot of network calls updating the api with new set of data.
I am making ...
1
vote
3
answers
1k
views
My Retrofit call.enque() method is getting skipped over entirely, not sure why
I'm making a call using Retrofit's enqueue() method. I'm calling my refreshImages() in my MainActivity's onCreate(), refreshImages() then calls a method refreshImagesIds() which is supposed to make a ...
-1
votes
1
answer
33
views
How to use json object that contains more json object
I am new to the calling API. I am calling API using Retrofit in Java. Sometimes I get that type of object.
{
"error": 0,
"msg": "Success",
"data": {
&...
0
votes
1
answer
25
views
Kotlin get value for response json list
I am new to Kotlin.
I trying to make an API call with retrofit.
when making the call to the api it responds to me:
{
"recordsets": [
[
{
"UsuarioId": 2101,
...
0
votes
0
answers
25
views
retrofit2.HttpException: HTTP 426 Error displaying while calling news Api
i am calling the api in a right manner but still giving http 426 error here is the full error.
FATAL EXCEPTION: main Process: com.example.news_api_jetpack_compose, PID: 7437
...
0
votes
0
answers
8
views
Tabbed Activity didn´t refresh the fragments data until I swipe down
I have a tabbed activity with three fragments and each fragment make a request to an API that shows the matches of the selected day in a date picker, the previous and the next one. When doing that, ...
0
votes
1
answer
177
views
My app doesn't display the data from an API with retrofit and moshi
I am a beginning computer science student. For school I have to make an app that can display data from an API. I use this API: http://openlibrary.org/search.json?q= The user of my app has to enter a ...
7
votes
3
answers
1k
views
Is there a possibility to exclude certain service calls for http logging?
In context of https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor is there a possibility to exclude some service calls?
In my app are 2-3 HTTP Calls, where I dont want, that the ...
0
votes
1
answer
51
views
Kotlin and Retrofit: HTTP FAILED: java.io.IOException: Canceled only in Fragment
I don't understand why it throws me this error when I make a call from a Fragment. If I make the call from MainActivity the code works.
This is the code in the ViewModel:
fun initialSync(syncRequest: ...
0
votes
2
answers
61
views
how to get user id with retrofit in android java
I am confuse to get UserId in android with retrofit, I have tried to get UserId into a Integer when I used getUserId(). It show an error
Incompatible types. Found: 'void', required: 'java.lang.Integer'...