Questions tagged [retrofit2]
Retrofit2 is the second version of the type-safe REST client Retrofit for Android and Java. It is developed by Square, Inc.
7,269
questions
-3
votes
0
answers
13
views
parse No Key json list with moshi in Android
What I am trying to do is to get Json response from GitHub API call of user's repository list.
response example from Github is like below.
[
{
"id": 78688034,
"node_id": &...
0
votes
1
answer
23
views
how to get the path of the image in android [duplicate]
Hello I'm trying to get the path of the image so I can send it to the server by using retrofit 2.0
So I keep getting the errors:
java.io.FileNotFoundException: : open failed: ENOENT (No such file or ...
0
votes
1
answer
26
views
How to solve android retrofit post image error 500
So I tried to upload image with multipart but i received 500 error code. I've tried it on postman and it worked well and it worked too with this code but without image. Am I wrong at multipart thing?
...
0
votes
0
answers
26
views
When retrofit2 won't return me Call in a typical implementation of CallAdapter.Factory()?
Given following implementation of Retrofit2 CallAdapter.Factory():
override fun get(
returnType: Type,
annotations: Array<Annotation>,
retrofit: Retrofit
): CallAdapter<*, *>? ...
0
votes
0
answers
32
views
Retrofit2: consume ASP.NET Web API with streaming files
How to consume this REST API (RestEase + ASP.NET Web API) using Android Retrofit2?
RestEase interface:
public interface IApiFile
{
[Get("DOWNLOAD")]
Task<Stream> DownloadAsync(...
0
votes
0
answers
14
views
Fetch current login user using Retrofit in Android
Can anyone help me with how can I fetch data from the only current users using Retrofit?
For web development, I do it like this
SELECT *
FROM job_register
WHERE job_assign ='{$_SESSION['username']...
0
votes
2
answers
27
views
I have error related retrofit dependency how can I resolve it?
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.squareup.retrofit2:retrofit:2.4.0.
I have this kind of error and how it to solve.
I have already added ...
0
votes
0
answers
21
views
Repeat request if get 202 code Android Kotlin RxJava 2
I need to implement a request retry if 202 code comes using RxJava 2, the problem is that when I try to do this, then with 202 code the response from the server is empty, and with a successful ...
1
vote
0
answers
18
views
Retrofit RxJava doesn't make multiple calls (Android)
I am trying to make repetitive calls with a timeout of 5 seconds with Retrofit2 on Android. The interface:
import com.google.gson.GsonBuilder
import io.reactivex.Observable
import okhttp3.OkHttpClient
...
0
votes
0
answers
38
views
How to send a POST request in Retrofit2 and make sure of it's delivery?
In my Android app the user takes orders which then are sent to a server, the server elaborates that orders and prints a receipt.
The main issue is that in most of the cases the server is not reachable ...
0
votes
0
answers
17
views
How I can deserialize various lists from server response json android kotlin?
In the app I have several types of server responses each of which is list: List<Model1> and List<Model2> and List<List<Model1>>. I have MVVM architecture and in ViewModel I ...
1
vote
0
answers
35
views
Android - Error Retrofit Multiple file upload
I'm trying to upload multiple files to a server backed with php and i'm facing the below error. I would appreciate it if you could help
FATAL EXCEPTION: main
Process: com.app.link, PID: 22253
...
0
votes
1
answer
35
views
Kotlin Retrofit return null to recylerView in .enqueue
So I'm trying to get data from an API with retrofit into a recycler view adapter. Everything works perfectly such as showing a list of data retrieve into list items. However, when press on the list ...
-2
votes
0
answers
33
views
Sharing same API between 2 activities
In very old java codebase, how we can share API between 2 Activity?
Also in old codebase we are not using RxJava, ViewModel,LiveData,Room.
For API Calling we have used Retrofit. After API Response ...
-1
votes
0
answers
18
views
Getting Data using Retrofit2
How to get data from this API
"https://api.genderize.io/?name=linda"
In the above API there is no relative url only base url and query part so how can I use it to get data using Retrofit.
I ...
0
votes
1
answer
23
views
How to cancel retrofit Response<T> type api calls?
How to cancel retrofit Response<T> api calls.
Like we have a function for Call class. Link: https://square.github.io/retrofit/2.x/retrofit/retrofit2/Call.html#cancel--
But there is no such thing ...
-1
votes
0
answers
20
views
i got 0 value from reponse retrofit with kotlin
i created a POST from android (FrontEnd) into PHP/MySQL (BackEnd).
it did insert the datas into my MySql, but why my object return has 0 value ?
eventhough the object is valued
my dataclas :
...
0
votes
1
answer
17
views
Is there any way to send the 8012 number as an error instead of printing it using PHP?
Inside MySQL, There is a Users table with three columns like this:
id (int)
name (char)
wallet_balance (int)
hasMembership (tinyint)
1
user1
125
0
2
user2
23
0
3
user3
986
0
Let's suppose the ...
0
votes
0
answers
66
views
Why is my app closing/breaking in the ViewModel when I try to send this Multipart Post?
I have been looking around for a month now at how to send a data class with an image to the server in Kotlin using Jetpack Compose. When I step through my app it makes it to the val call = retrofit....
0
votes
0
answers
19
views
Android kotlin calling same api with different date params and inserting to room all together
I have an api to return data based on from and to date params. The api is limited to return only 1 day data at a time. I need to fetch data for 7 days and insert it to room db. Fetching day by day and ...
0
votes
1
answer
22
views
User Defined Base URL With Retrofit
The application I work on must use a different Base URL for every user. Basically the user has his own server, and in the application he must specify the IP Address for his server in a Text Field so ...
1
vote
0
answers
45
views
The Response doesn't Succeed return "0"
There is a problem when receiving the response,
response.body().success
it returns 0 but I expect 1
it shows a toast shows Failed! As the code below which means the response doesn't succeed
mService =...
-2
votes
1
answer
34
views
Null point object reference in retrofit
im trying to get data using Retrofit2 to call API. when i open my app it crash immediately. i tried a lot of solutions. i use postman and still see all the data is in json format. can anyone help me? ...
1
vote
0
answers
26
views
Retrofit2 Inconsistency Response from Server in android java
I am new to Android development and learning how to use Retrofit and I am having a hard time to deal with inconsistency response from the server.
There are more than two kinds of responses will be ...
0
votes
2
answers
39
views
callback always fails with retrofit url
this is the mainactivity
val url:String="http://api.brainshop.ai/get?bid=167083&key=jIpZgrpRgALYSZ72&uid=[uid]&msg="+message
val BASE_URL="http://api.brainshop....
1
vote
1
answer
34
views
Retrofit2 automatically removes the header with the content type
I'm trying to send a POST request with a body and two headers: a cookie and a content type
In the chuckerinterceptor, I see that the header with the content type is lost in the request, I found ...
0
votes
0
answers
27
views
How to send JsonObject Post request with image using Retrofit (Java)
I want to send a post request which contains jsonObject and an image and various other fields and I used MultiPart for image and have successfully uploaded the image but the jsonObject is uploaded in ...
0
votes
0
answers
21
views
How do I get access token from API
Tech stack:
Kotlin, Retrofit2
What I want to do:
I want to get access token from API
My method to get access token is
https://demo2.gopos.pl/oauth/token?password={password}&grant_type=password&...
2
votes
1
answer
43
views
[Android][Retrofit] Using interceptor to call different API
I am working on an Android project which uses retrofit to handle network calls. I have a hard time figuring out a use case.
I have an API (api1) which has already been implemented and is being called ...
0
votes
0
answers
21
views
Is it possible to use same provide function which will give diff object based on service in Retrofit Hilt?
I want to use this single function only, but instead of UserAPIService, there may be ProductAPIService on runtime based on what user is clicking. Is that possible?
Code:
@Provides
@Singleton
fun ...
0
votes
0
answers
26
views
How do I implement @POST in Retrofit and save oAuth2 token?
I'm using Kotlin and Retrofit2
What I would want to do:
I would want to get an access token and save it somewhere so I could use it later. How implementation should look like using Retrofit2? ...
0
votes
0
answers
42
views
How to Post Raw Json Object in Android (Java) using Retrofit without POJO class
There Are Two Activities, Activity A & Activity B
I Made an API Call in activity A And converted the JsonObject into string for my further Use, Now I Again Converted it to JsonObject Using ...
0
votes
1
answer
25
views
Retrofit Enqueue parsing a Json object without an additional class
I have working code that allows me parse the Json files I get from a retrofit API get call. However, the way I am currently doing it requires two classes (one of which is just a list containing the ...
0
votes
0
answers
20
views
Android, Retrofit2, get request string
I'm using Retrofit2 to get data in my Android applications. It looks like this:
interface ApiChatService {
@GET("ncs-chat-web/rest/v1/message")
suspend fun getChatMessages(@Header(&...
0
votes
2
answers
68
views
Use Retrofit with another request/response protocol in Android
I want to use Retrofit to adapt responses using another request/response protocol for IoT (not HTTP, but very similar in terms of architecture) in my Android application. Notably, I suppose the other ...
0
votes
0
answers
27
views
Default constructor in android.os.AsyncTask is deprecated to using android 11 devices
Helo friend,
Try to upload pdf on android 11 or 12 using retrofit2, i keep see error from onPostExecute
protected void onPostExecute(String s) {
super.onPostExecute(s);
if(s!=null){
...
0
votes
0
answers
33
views
Receiving and Convert JSON data to Java Object
I want to store "data" Data :
{
"api_status": 200,
"data": [
{"id": "755", "post_id": "755", "publisher": { "...
0
votes
2
answers
55
views
How to post nested array object with kotlin using retrofit
I'm trying to use post method in retrofit but confused how to implement it
How can I implement a retrofit using the post method?
{
"companyId": "id8921",
"employee&...
1
vote
1
answer
93
views
How to POST and GET that data from a web API. (Retrofit/Kotlin/Android)
I'm new to web APIs and retrofit. I'm interacting with TheCatApi and having trouble fetching data that I posted. The API has a list of images and a feature to choose several as favorites with POST ...
-1
votes
0
answers
69
views
Android Studio - Pick PDF file and upload with Retrofit [open failed: EACCES (Permission denied)]
I need to be able to select a file and send it via Retrofit. But after selecting the file I get the following error when sending it with Retrofit:
java.io.FileNotFoundException: /storage/emulated/0/...
0
votes
0
answers
28
views
Retrofit MVVM delay in response
I implemented a recycler view in a fragment which will be updated based on the text entered in searchview. As soon a text entered in searchview which is in MainActivity. I'm calling onQueryTextChange(...
0
votes
0
answers
22
views
Use JsonReader.setLenient(true) to accept malformed JSON in kolin using retrofit
I am using retrofit2 for API calls. When it called to my API it shows below error;
Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $
#Step1: Here is my JONSON
[
...
0
votes
1
answer
70
views
Why does the String coming in POST request body come with additional quotes and get not a JSON Object
I am calling a RestFul API written in Java that consumes plain text or JSON and returns a response in JSON. I am using gson library to generate and parse my fields. I am calling the api from an ...
0
votes
0
answers
19
views
how to use Retrofit to post a request with some data in the body
I'm trying to create a translation app using kotlin and retrofit. the request is as following :
curl -X POST "https://api.lecto.ai/v1/translate/text" -H 'X-API-Key:'' -H 'Content-Type: ...
0
votes
0
answers
17
views
Displaying images in recyclerview retrieved from retrofit
I'm new in android development and building a movie app in which I'm using recyclerview to display movie images and using retrofit to fetch data from themoviedb.org API.
I'm successfully getting the ...
0
votes
0
answers
60
views
Expected BEGIN_OBJECT but was STRING at line 1 column 4 path
I see a couple of these non-fatals in Crashlytics from our release. I know what the error means and I've looked at the solutions from other posts on StackOverflow. However, I cannot reproduce this ...
0
votes
2
answers
60
views
Parsing JSON Strings with moshi and retrofit2
The API I am using responds with a JSON object nested inside a list, like so:
[
{
"name": "Seattle",
"lat": 47.6038321,
"lon": -122....
0
votes
1
answer
54
views
How to convert POST curl request to Retrofit Request in Android?
I'm trying to represent the below curl request in android using Retrofit,
curl -i -X POST \
https://graph.facebook.com/v13.0/1234567890/messages \
-H 'Authorization: Bearer ucuzZCQv9qb--token--...
1
vote
1
answer
27
views
Andriod Retrofit 2: Refreshing Recycler View From from another Activity
So I have a app where I am displaying the products list from the database using a Recycler View.
There is delete button beside each item which is working fine.
And there is a scan item button which ...
0
votes
0
answers
44
views
Android Retrofit call at specific time daily
I am creating an application (following the MVVM architecture) for which I want to send requests to the server once on a daily basis exactly at 00:05 (of user's timezone). I tried creating a service ...