retrofit2

Retrofit 2.0, request GET to a .json file as endpoint

大憨熊 提交于 2020-05-13 04:43:52
问题 Hello Im working in a test with Retrofit 2.0 and one of the test is making a resquest to a url that finish with .json: Example: https://domain.com/contacts.json baseURl: https://domain.com/ endPoint: /contacts.json Which is a file, but I want to make a normal GET request and get the json inside directly 回答1: If you have control over your web server, you can customize it supports .json file as text/plain or application/json . Please see my following screenshot (I have done with IIS 7.5) The

Retrofit 2.0, request GET to a .json file as endpoint

痞子三分冷 提交于 2020-05-13 04:41:25
问题 Hello Im working in a test with Retrofit 2.0 and one of the test is making a resquest to a url that finish with .json: Example: https://domain.com/contacts.json baseURl: https://domain.com/ endPoint: /contacts.json Which is a file, but I want to make a normal GET request and get the json inside directly 回答1: If you have control over your web server, you can customize it supports .json file as text/plain or application/json . Please see my following screenshot (I have done with IIS 7.5) The

How is it possible that POST API working in Postman but not the retrofit?

拜拜、爱过 提交于 2020-04-30 06:42:05
问题 I'm trying to hit one login API, which also need some headers and body. with the latest version of retrofit, I tried to send headers in both way either with annotation or programatically way, but everytime it says error code 417, exception failed and error body is null, but in postman I'm getting proper reponse. 回答1: you can use HttpLoggingInterceptor to compare requests and find out what is wrong. 来源: https://stackoverflow.com/questions/60332781/how-is-it-possible-that-post-api-working-in

Error 400, Bad Request, Json Parse error: Unrecognized token 'agama' : was Expecting ('true','false', or 'null') in Android Retrofit with Spring Boot

只谈情不闲聊 提交于 2020-04-30 06:26:21
问题 I have this kind of JSON: EDITED { "tgl_Lahir": "1960-12-18 00:00:00", "nama": "Rahmi P", "keterangan": "HIDUP", "tempatLahir": "YOGYAKARTA", "noPegawai": "010713", "golDarah": "0", "statusNikah": "0", "hubungans": { "id": "10" }, "agama": { "id_Agama": "1" }, "jeniskelamin": { "jenisKelamin": "1" } } I have this interface class: @FormUrlEncoded @POST("http://ipaddress/family/add") Call<familylistresponse> addFams(@Header("Content-Type") String content_type, @Header("Authorization") String

Error 400, Bad Request, Json Parse error: Unrecognized token 'agama' : was Expecting ('true','false', or 'null') in Android Retrofit with Spring Boot

感情迁移 提交于 2020-04-30 06:26:07
问题 I have this kind of JSON: EDITED { "tgl_Lahir": "1960-12-18 00:00:00", "nama": "Rahmi P", "keterangan": "HIDUP", "tempatLahir": "YOGYAKARTA", "noPegawai": "010713", "golDarah": "0", "statusNikah": "0", "hubungans": { "id": "10" }, "agama": { "id_Agama": "1" }, "jeniskelamin": { "jenisKelamin": "1" } } I have this interface class: @FormUrlEncoded @POST("http://ipaddress/family/add") Call<familylistresponse> addFams(@Header("Content-Type") String content_type, @Header("Authorization") String

Android having problems while uploading Images using Retrofit multipart?

久未见 提交于 2020-04-21 06:36:27
问题 I'm getting the following error while trying to upload an Image to a server using retrofit, the api receives a header authorization token, _method = "put" and image = "imageName.jpg" as parameters, everything else is optional, any help would be appreciated. java.io.FileNotFoundException: /storage/emulated/0/Download/space-wallpaper-21.jpg: open failed: EACCES (Permission denied) userImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { galleryIntent =

Android having problems while uploading Images using Retrofit multipart?

拈花ヽ惹草 提交于 2020-04-21 06:34:19
问题 I'm getting the following error while trying to upload an Image to a server using retrofit, the api receives a header authorization token, _method = "put" and image = "imageName.jpg" as parameters, everything else is optional, any help would be appreciated. java.io.FileNotFoundException: /storage/emulated/0/Download/space-wallpaper-21.jpg: open failed: EACCES (Permission denied) userImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { galleryIntent =

retrofit 2 @headers error in kotlin

感情迁移 提交于 2020-04-12 08:57:12
问题 I try to add multiple static headers with retrofit 2 (2.3.0) like this : interface WeatherAPI { @Headers({ "Accept: application/json", "Content-type:application/json" }) @GET("/data/2.5/weather") fun getWeatherForCityName(@Query("q") city: String, @Query("appid") appid: String) : Call<GetWeatherResponse>; } I have the folowing error : Any idea of my mistake? 回答1: Braces {} isn't needed inside @Headers . Docs: https://kotlinlang.org/docs/reference/annotations.html#arrays-as-annotation

Dagger 2 cannot access Retrofit

天大地大妈咪最大 提交于 2020-04-08 09:05:21
问题 I'm trying to provide an instance of Retrofit to my Repository using Dagger 2 (with Android module). Buy I'm facing the error: Error:cannot access Retrofit Other instances like Picasso was injected with success, I just have problems with Retrofit. My Module @Module class NetworkModule { @Provides @Singleton fun providesRetrofit(): Retrofit { return Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create()) .baseUrl(URL_BASE) .build() } @Provides @Singleton fun providesPicasso

Dagger 2 cannot access Retrofit

a 夏天 提交于 2020-04-08 09:03:56
问题 I'm trying to provide an instance of Retrofit to my Repository using Dagger 2 (with Android module). Buy I'm facing the error: Error:cannot access Retrofit Other instances like Picasso was injected with success, I just have problems with Retrofit. My Module @Module class NetworkModule { @Provides @Singleton fun providesRetrofit(): Retrofit { return Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create()) .baseUrl(URL_BASE) .build() } @Provides @Singleton fun providesPicasso