Category : retrofit2

I am working on an Android App with Retrofit2 and OkHttp and it´s the first time that I use both frameworks. The Retrofit Request fails with the error message " java.lang.NullPointerException: client == null" in Line 138 of my Android Service class: static Retrofit retrofit = new Retrofit.Builder().baseUrl(PalletteApi.BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .client(okHttp) .build(); the okHttp Instance that ..

Read more

I’m using Google Codelab to learn HTTP request using Retrofit/Moshi in kotlin . https://codelabs.developers.google.com/codelabs/kotlin-android-training-internet-data/#4 Right now, I’m trying to access a nested JSON object of Google Books API but im not able to parse it. { "kind": "books#volumes", "items": [ { "id": "t4rgAAACAZAJ", "volumeInfo": { "title": "Harry Review", "authors": [ "International ISBN Agency" ], "imageLinks": ..

Read more

I’m trying to develop a app with based_token auth using laravel/sanctum and kotlin, i’m a beginner. I already implemented sanctum and tested in postman and work perfectly, but when i’m going to use android emulator from android studio retrofit calls return always 401. for connect device(android emulator) and postman to laravel i used php artisan ..

Read more

I am developing an Android application in which I would like to call an API using Retrofit. The requires authorization token in the header and I added the same as well. Below are the code snippets RetrofitClient.kt object RetrofitClient { var apiInterface: APIInterface? = null val okHttpClient = OkHttpClient.Builder() .connectTimeout(300, TimeUnit.SECONDS) .writeTimeout(300, TimeUnit.SECONDS) .readTimeout(180, TimeUnit.SECONDS) ..

Read more

YoutubeData.java package bsi.ekosantoso.movieapi; public class YoutubeData { private int id; private String key; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getKey() { return key; } public void setKey(String key) { this.key = key; } public String getName() { return name; } ..

Read more

I am developing currency app but when I am trying to implement network call in mainactivity.kt it is giving an error I did not understand where exactly I am making an error below my MainActivity.kt where I have implemented retrofit network call class MainActivity : AppCompatActivity() { private var listUsers: MutableList<Quotes> = mutableListOf<Quotes>() private var ..

Read more

I have read quite a few resources and tutorials so far, and I still haven’t found the solution I need. The problem is that my application using Retrofit 2 does not send requests to my own server. Empirically, it was revealed that requests are not sent only to addresses using http. Requests were sent to ..

Read more