retrofit2

java.lang.IllegalArgumentException: Illegal URL with retrofit

我是研究僧i 提交于 2019-11-29 14:38:40
i'm trying to call an api in my application i've the following url template test-test.domainname.com/feeds/json/v3/attribute/attribute i'm using retrofit 2 but i get the following fatal exception Illegal URL: test-test.domainname.com and this is my interface public interface Iinterface{ @GET("feeds/json/v3/attribute/"+attribute) Call<ArrayList<result>>getresult(); } can someone help me with this problem ... Yasin Kaçmaz my base URL is here: http://myapiname.azurewebservices.net and feed method is like that : public interface Iinterface{ @GET("/feeds/json/v3/attribute/"+attribute) Call

Expected BEGIN_ARRAY but was BEGIN_OBJECT retrofit2

寵の児 提交于 2019-11-29 12:17:05
I have some problem about retrofit2 How to fix Expected BEGIN_ARRAY but was BEGIN_OBJECT in retrofit2 I don't know to fix it What's my wrong ? my json is { "result": true, "message": "success", "data": [ { "id": "10", "type_name": "pppppp" }, { "id_mt": "11", "type_name": "aaaaaa" } ] } and my model class is public class MessageFastModel { private boolean result; private String message; private List<DataBean> data; public boolean isResult() { return result; } public void setResult(boolean result) { this.result = result; } public String getMessage() { return message; } public void setMessage

Centralized error handling retrofit 2?

女生的网名这么多〃 提交于 2019-11-29 12:10:31
问题 Before retrofit 2, there was a way of handling erros centrally - new retrofit.RestAdapter.Builder() .setEndpoint(apiUrl) .setLogLevel(retrofit.RestAdapter.LogLevel.FULL) .setErrorHandler(new CustomErrorHandler(ctx)) But now in Retrofit 2, RestAdapter has been renamed to Retrofit and there is no setErrorHandler() . Is there a way to have centralized error handling using Retrofit.Builder() ? 回答1: You have to make a custom CallAdapter with your custom service success or error callbacks. Jake

How to call API Gateway with Cognito Credentials through retrofit2 on Android?

元气小坏坏 提交于 2019-11-29 09:41:10
问题 I use retrofit2 in my android apps for any http/rest call. Now I need to call an api generated with Amazon AWS API Gateway. The AWS documentation say I should generate the client code throw the API Gateway console and use the class ApiClientFactory to build the request: ApiClientFactory factory = new ApiClientFactory(); // Use CognitoCachingCredentialsProvider to provide AWS credentials // for the ApiClientFactory AWSCredentialsProvider credentialsProvider = new

RxAndroid and Retrofit: Unable to create call adapter for io.reactivex.Observable<retrofit2.Response<okhttp3.ResponseBody>>

主宰稳场 提交于 2019-11-29 09:24:45
I am trying use rxJava, rxAndroid, Retrofit2, and OkHTTP3 to download a file from a URL endpoint. My code is unable to create the call adapter for an "Observable< retrofit2.Response< okhttp3.ResponseBody>>". These methods are new to me so I believe I'm missing an important concept here. Any direction or points is greatly appreciated. FATAL EXCEPTION: main Process: com.example.khe11e.rxdownloadfile, PID: 14130 java.lang.IllegalArgumentException: Unable to create call adapter for io.reactivex.Observable> for method RetrofitInterface.downloadFileByUrlRx at retrofit2.ServiceMethod$Builder

java.lang.NoClassDefFoundError retrofit2.Utils

[亡魂溺海] 提交于 2019-11-29 08:57:19
问题 I'm using Retrofit to handle the Serverside Data from Mobile. After Implementing retrofit, I am Getting the below Exception. What am I doing wrong? com.name.App_idea W/System.err: java.lang.NoClassDefFoundError: retrofit2.Utils at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:434) at com.name.App_idea.utils.Idea.onCreate(Idea.java:103) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007) at android.app.ActivityThread.handleBindApplication(ActivityThread.java

Parameter does not have a match; SimpleXML

风流意气都作罢 提交于 2019-11-29 07:31:13
I am using retrofit with the SimpleXMLConverterFactory . And I always get an ConstructorException: Parameter 'success' does not have a match in class ResponseInfo And I have no idea what could be wrong. The xml is very simple and i only want the string from the success node. xml: <?xml version="1.0" encoding="UTF-8"?> <response> <success>LoremIpsum</success> </response> ResponseInfo: @Root(strict = false, name = "response") data class ResponseInfo(@Element(required = false, name = "success) var success: String) Edit 1: I tested the Api call and it returns the given xml. Thanks lampenlampen So

How to get raw response and request using Retrofit 2.0

∥☆過路亽.° 提交于 2019-11-29 05:49:23
I am trying to get the raw response using Retrofit2.0.2. So far I tried to print the response using following line of code but it prints the address and not the exact response body. Log.i("RAW MESSAGE",response.body().toString()); compile 'com.squareup.retrofit2:retrofit:2.0.2' Retrofit retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); GitApi gitApi = retrofit.create(GitApi.class); Call<Addresses> call = gitApi.getFeed(user); call.enqueue(new Callback<Addresses>() { @Override public void onResponse(Response<Addresses> response,

Retrofit 2 check call URL

拈花ヽ惹草 提交于 2019-11-29 04:40:09
Is there any possibility to compare a Call URL with a String in Retrofit 2 ? For example we can take this baseUrl : https://www.google.com And this Call : public interface ExampleService { @GET("dummy/{examplePartialUrl}/") Call<JsonObject> exampleList(@Path("examplePartialUrl") String examplePartialUrl; } with this request: Call<JsonObject> mCall = dummyService.exampleList("partialDummy") There's a way to obtain https://www.google.com/dummy/partialDummy or also dummy/partialDummy before getting the response from the call? trevor-e Assuming you're using OkHttp alongside Retrofit, you could do

Android - Retrofit 2 - Authenticator Result

こ雲淡風輕ζ 提交于 2019-11-29 03:46:36
问题 I'm trying to use Retrofit (2.0.0-beta3), but when using an Authenticator to add a token, I can't seem to get the data from the synchronous call. Our logging on the back-end just shows a lot of login attempts, but I can't get the data from the body to actually add to the header. public static class TokenAuthenticator implements Authenticator { @Override public Request authenticate(Route route, Response response) throws IOException { // Refresh your access_token using a synchronous api request