Questions tagged [retrofit]

1

votes
0

answer
65

Views

Room LiveData onChange called too fast. Many Activities stacked atop

@Dao public interface LibraryCoverContentDao { @Query('SELECT * FROM LibraryCoverContent where rush_id = :rush_id') LiveData getContentsFromRushID(String rush_id); @Query('DELETE FROM library_cover where rush_id = :rush_id') void deleteContentsFromRushID(String rush_id); @Insert(onConflict = REPLACE...
Robillo
1

votes
1

answer
340

Views

Send file to the server with Retrofit and WebKitFormBoundary in PartMap

I have a query generated by the postman to send files and some info to my server. It works fine in my program. MediaType mediaType = MediaType.parse('multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'); RequestBody body = RequestBody.create(mediaType, '------WebKitFormBoundary7MA4...
Joao
1

votes
0

answer
107

Views

How do I send a secure cookie over HTTPS on Android Retrofit 2/OkHTTP3?

I'm using Retrofit 2. For some reason, my Android app can never succeed calling backend Django API due to CSRF token failure because CSRF_COOKIE_SECURE is set to True. So how do I send the cookies over OkHttp3 and Retrofit 2 as secure (over HTTPS)?
waynejohn1110
1

votes
0

answer
49

Views

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1- Retrofit

i'm using retrofit for my app. when i try to access webservice,onFailure i'm getting Expected BEGIN_OBJECT but was STRING at line 1. this is postman response { 'status': true, 'message': 'order status updated' } Oncreate Gson gson = new GsonBuilder() .setLenient() .create(); HttpLoggingInterceptor...
user8164155
1

votes
0

answer
44

Views

App using Retrofit 2 waits for one minute before exiting

I'm using Retrofit 2 to make asynchronous calls. The problem is that after the response is received (onResponse is done with its work), the application still waits for 60 seconds before quitting. This is the essential bit: Call call = client.resource(); call.enqueue(new Callback() { @Override public...
naktinis
1

votes
0

answer
708

Views

Android posting to https using retrofit

I found similar post on How to post HTTPS request using Retrofit? but it does't help me that much so i was wondering if some of you could help. This is my first post on SO and if you need any more information please let me know. This is my code public static OkHttpClient getUnsafeOkHttpClient() { tr...
Mihovil Maricic
1

votes
1

answer
571

Views

How to POST JsonObject with Retrofit 2?

In my app I'm creating a JsonObject JSONObject jsonObject = new JSONObject(); jsonObject.put('command', 'session.intSessOK'); jsonObject.put('appToken', appToken); jsonObject.put('aesIv', aesIv2Encrypted); jsonObject.put('nextToken', nextToken); putting values in it byte[] body = Base64.encode(jsonO...
Ege Kuzubasioglu
1

votes
0

answer
426

Views

Cannot parse Json to data class using kotlinx.serialization

In an Android project, I am trying to parse a Json response from a remote endpoint using kotlinx.serialization and Retrofit. I am using Jake Warthon's https://github.com/JakeWharton/retrofit2-kotlinx-serialization-converter to set the converter when setting up the retrofit instance Retrofit.Builder(...
Nicolás González
1

votes
1

answer
48

Views

How to use custom converter?

I want to parse time from 00:00:00 ... as long I defiend items as @Root(strict = false) private static class Item { @Element(name = 'time') @Convert(TimeConverter.class) private Long time; } My Converter public class TimeConverter implements org.simpleframework.xml.convert.Converter { SimpleDate...
Yarh
1

votes
1

answer
379

Views

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/okhttp/OkUrlFactory

I want to set timeout in retrofit I added compile 'com.squareup.okhttp:okhttp:1.6.0' to set timeout in Retrofit application is crashing and showing error java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/okhttp/OkUrlFactory here is my code Gson localGson = new GsonBuilder().create(...
satyender
1

votes
1

answer
956

Views

How to get access token in retrofit

i'm creating a registration app, i already got client id and secret, now i have to do get request and get access token and refresh token. I have this link https://supptop.mymix.net/api/token?grant_type=password&cl[email protected]gmail.com&password=pass...
1

votes
0

answer
203

Views

How can I update Reyclerview after async-call with ViewModel

I use Android Architecture Components(LiveData + ViewModel, MVVM). I have a list of items as news feed, which I represent over recyclerview. The user can like an item on this feed, and then after retrofit success, this certain item should be then updated (count of likes & viewclicks are observable-f...
BestPractice2Go
1

votes
0

answer
301

Views

Authorization header not recognized by Yelp Fusion API

I am passing an authorization header with my Retrofit GET requests as documented by the Yelp Fusion documentation, which is shown below: Authorization: Bearer MY_API_KEY I am adding a network interceptor in my onCreate() method as shown below: OkHttpClient.Builder okHttpBuilder = new OkHttpClient.Bu...
Ahmed Hakeem
1

votes
1

answer
545

Views

getting too many follow-up request as response of request

we have a Restful web service created using Jersey and running on TomEE 7.0.3 we are using Android platform for client-side and it's using Retrofit for having communication with the server. our system is modular and contains more than 14 parts. about 3 weeks (until now), sometimes the clients gettin...
Seyed Ali Roshan
1

votes
1

answer
68

Views

Handling more than 1 response in retrofit [duplicate]

This question already has an answer here: How can we handle different response type with Retrofit 2? 2 answers i Have 2 responses in my api response one for success if the data is correct and one for incorrect data i can't handle it with my pojo class and this is my class public class AirCraftSear...
Yehia Ahmad
1

votes
4

answer
451

Views

How to Parse nested json using Retrofit?

I want to parse nested json using retrofit and bind it in recyclerview. Am familiar with Parsing simple json using Retrofit. But i dont know how to parse nested json using retrofit. i am newbie to retrofit. any help will be appreciated ? Here is that Link: http://api.wunderground.com/api/356d60036a9...
1

votes
2

answer
521

Views

Retrofit Error when I try to get the data from the server

I did the register functionality and it worked fine but when I want to get data from the server I ran into this problem. Here is my retrofit class public class ApiClient { private static final String BASE_URL = 'http://10.0.2.2/LOGIN/'; public static Retrofit retrofit; public static Retrofit getApiC...
Amir
1

votes
0

answer
37

Views

Retrofit 2 Multipart sends only image instead of image and data

I'm developing an app using Retrofit 2 for getting and sending data to API. When I try to upload an image with Multipart, API Logs that it hasn't got all data that I've sent to it. Here is my code: Service interface method: @Multipart @POST('photoUpload') Call uploadPhoto(@Header('Accept') String ac...
FogNature
1

votes
2

answer
67

Views

How to add a key to a post/put request in retrofit2

I am new to retrofit and I was wondering if there is a better approach to get this result while making a put/post request: 'user': { 'owner_id': 1, 'first_name': 'test', 'middle_name': 'test2', 'last_name': 'test3' ... } Right now in order to obtain this I have this model: public class User implemen...
Alphonse
1

votes
2

answer
414

Views

Set Retrofit Base URL from Strings.xml file located on res/values folder [duplicate]

This question already has an answer here: how to read value from string.xml in android? 16 answers I need to set retrofit base URL from Strings.xml file. However, the service generator can't access the Context class in Android. Can anyone give any advice? Here's the snapshot of my code private stat...
Eldwin Eldwin
1

votes
2

answer
196

Views

Retrofit doesn't call onReponse and onFailure

In my case I have used retrofit to contact with rest api. Unfortunately when i start it never reach onResponse and onFailure state neither. I checked in debug line after line and it looks that he proceed to line: call.enqueue(new Callback() { and subsequently it goes back to the beginning loop, pro...
Armin Orlik
1

votes
2

answer
93

Views

Retrofit GSON Parsing dynamic repsonse (key names unknown)

I am trying to parse below json response in retrofit/gson, specifically this json { 'Coincheck':{ 'BTC':[ 'JPY' ] }, 'QuadrigaCX':{ 'ETH':[ 'CAD', 'BTC' ], 'BTC':[ 'USD', 'CAD' ] } // ... more data } I tried using Map< String, Map< String, List< String>> public class ExchangeResp { Map...
Ajay
1

votes
3

answer
704

Views

Retrofit handling empty Jsonarray

I have retrofit built up like this : public static Retrofit getClient(MCrypt mCrypt) throws Exception { if (retrofit == null) { OkHttpClient okHttpClient; if (BuildConfig.DEBUG) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BOD...
S.P
1

votes
1

answer
49

Views

Inflate dynamic layout for displaying questionnaire from JSON

How to inflate dynamic layout for displaying questionnaire from JSON using Retrofit? I am getting list of questions from web service and I need to display it in UI dynamically
Garrima Kakkr
1

votes
0

answer
198

Views

How to properly unit test Retrofit callbacks with Mockito? MVP and Dagger2 used

I download Posts of the users from server using Retrofit and put information into Recycler View. Download is implemented in presenter class and recycler view is located in activity. I would like to test wheter the adapter for Recycler View changes its size after successful response by mocking my web...
TomaszKopacz
1

votes
0

answer
127

Views

how to handle failure response in retrofit 2.0

I'm working on retrofit 2.0 i have set everything right i'm getting the correct token but at the end message goes to failure. i have also made one response class which i'm getting through postman. i have also appended a bearer token there.i have tried everything but non of them work. Main activity...
Balwinder
1

votes
0

answer
770

Views

How to solve java.io.EOFException: End of input at line 1 column 1 path 1 in retrofit service call in android?

I am new to android. I am not getting why this error is coming. Error : java.io.EOFException: End of input at line 1 column 1 path $ W/System.err:at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1393) Please help. This is my code : 1. Pojo class ProfileEntity implements Parce...
Risk
1

votes
1

answer
34

Views

How do I get the web service to execute before return statement?

I have a method that is returning a boolean value from a web service call. Problem is it that it is is executing the return statement (returning a false value every time the method is called) then returning to the method and executing the web service call after (which gives a true value that is not...
Thapelo M
1

votes
0

answer
219

Views

Retrofit returns not working access token

I'm creating an authorization app, where user registers and gets client_id, client_secret, access_token and refresh_token. I have one API where i need to do call. In that call I use my access_token. All works great. But the access_token expires after hour, so with refresh_token I'm updating my acces...
Hayk Mkrtchyan
1

votes
1

answer
438

Views

Android retrofit POST method with String Query param double quotes in newer versions

I have this retrofit method for an API: @POST('/searchCity/byname') Call searchCityByName(@Query('name') String name); It being called this way from the code: final String cityName ='City' restClient.getApiService().searchCityByName(cityName); And whenever I send a request with retrofit 2.1.0 the ur...
Rodri de Blas
1

votes
1

answer
201

Views

How to retrieve objects with different names from the same url using Retrofit

I'm using Retrofit in order to retrieve the data from an API. This is the url http://mindicador.cl/api and I need to retrieve the objects with the name of 'uf', 'dolar', 'euro' and 'utm', all those four in one call. This is my Java class based on the json. public class IEconomicoAPI { private Strin...
Miguel Barra
1

votes
1

answer
64

Views

Having problems making simultaneous retrofit 2 calls work side by side as intended

I have 2 spinners and 1 RecyclerView in my mainfragment in my mainactivity that I want populated at startup using retrofit. In my mainfragment's onViewCreated(), I do both of these calls (fetchDistricts() and fetchPremiumStudios()) but the recyclerview remains empty (fetchPremiumStudios) while the s...
Ganesh T
1

votes
2

answer
1.4k

Views

Where to put API Key using retrofit in Android Studio

I am creating a News app using api key from newsapi.org This is my code for Interface which i have created using tutorial found on https://www.learn2crack.com/2016/02/recyclerview-json-parsing.html.I am confused what is the syntax and where to put api key in this interface. public interface RequestI...
Abhishek Kumar
1

votes
1

answer
379

Views

Retrofit not working on release version of app

I am using Retrofit in my app. Everything is working fine but when I create the release version of the app some calls aren't working. What could the problem be? I already disabled minifyEnabled in my gradle file. Edit: Found the real problem: I get the user data by a specific API call. I map this on...
Bart Bergmans
1

votes
1

answer
191

Views

refresh token rxjava+retrofir2

When registering in the application user gets 2 tokens. Access (lives 1 day) and Refresh (lives 6 months). At a certain point, the Access token will come-one day there will be a custom error. At this , we need to call the refreshToken method and the updated , with which the work will go on. We call...
JunDev
1

votes
0

answer
48

Views

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY

Following is link of JSON data: http://elearnup.com/ajax/classes And this is JSON accessing code in Activity using retrofit : private void getAllInputValue() { Log.d('checekntest', 'getAllInputValue: checktest'); Call allInputDataApiCall = apiGet.getDataInput(); allInputDataApiCall.enqueue(new Callb...
Manoj Budha Ayer
1

votes
1

answer
142

Views

Zip method in RXJava

I am learning RX Java where I would like to send N parallel requests to a web API and the combined results would be merged to one List. I am using Retrofit with RXJava extensions to send the requests: @GET('getForkliftDetail') Observable getForkliftDetail( @Query('lang') String language, @Query('id'...
Angelina
1

votes
0

answer
176

Views

Image file inside nested json body with RetroFit 2.0

I'm trying to upload an image from my Android app using Retrofit 2.0. The request body has to be like this. I'm used to using @MultiPart for image uploads, but I can't figure out how to put the image inside a nested JSON. { 'user': { 'profile': { 'id': id 'image': { 'photo': photo } } } }
Abhishek Jacob
1

votes
1

answer
358

Views

Android URL Encoding for colon %3A in GET command

I am new to java and I am trying to do some URL encoding to retrieve plex livetv directories with GET command. The issue I am having is with the colon ':' if I use the colon, I get this error, but if I use URL encoding 'tv.plex.providers.epg.onconnect%3A23' I get a blank livetv library. What is t...
Matthew Gorski
1

votes
1

answer
82

Views

openweathermap API has section in square brackets, can't call that json data in Android Studio

So I am trying to make a weather app, the API works but only in certain areas. For now I am just trying to make a Toast of the API to make sure it works before I go on to do the rest of the app. public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInst...
Haych

View additional questions