retrofit2

Unable to create call adapter for io.reactivex.Observable

醉酒当歌 提交于 2019-11-30 11:42:42
问题 I'm going to send a simple get method to my server(it is Rails app) and get the result using RxJava and Retrofit. The thing that I did is: My interface: public interface ApiCall { String SERVICE_ENDPOINT = "https://198.50.214.15"; @GET("/api/post") io.reactivex.Observable<Post> getPost(); } My model is this: public class Post { @SerializedName("id") private String id; @SerializedName("body") private String body; @SerializedName("title") private String title; public String getId () { return id

How can I return value from onResponse of Retrofit v2

荒凉一梦 提交于 2019-11-30 10:18:15
I want to return a string value from my function. But I do not know how to handle it? I tried final one-array solution but it did not work out. Here is my code: public String revealCourtPlace(String courtID) { BaseService.getInstance().getUniqueCourt(Session.getToken(),courtID).enqueue(new Callback<JsonObject>() { @Override public void onResponse(Call<JsonObject> call, Response<JsonObject> response) { JsonObject object = response.body(); boolean success = object.get("success").getAsBoolean(); //json objesinde dönen success alanı true ise if (success) { JsonArray resultArray = object.get("data"

Firebase device to device messaging using Retrofit, how do i get message id?

我是研究僧i 提交于 2019-11-30 07:42:52
问题 I use Retrofit for sending device to device message without php script and curl command and everything work fine. I need to save sent message ID. How can i get after success sending message ID for sent message. My code. Sending activity public void onClick(View view) { HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); logging.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(new Interceptor() {

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

岁酱吖の 提交于 2019-11-30 07:30:23
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 CognitoCachingCredentialsProvider( context, // activity context "identityPoolId", // Cognito identity pool id Regions.US_EAST_1 //

java.lang.NoClassDefFoundError retrofit2.Utils

南笙酒味 提交于 2019-11-30 07:13:36
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:4541) at android.app.ActivityThread.access$1500(ActivityThread.java:151) at android.app.ActivityThread$H

Android - Retrofit 2 - Authenticator Result

▼魔方 西西 提交于 2019-11-30 05:40:59
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 UserService userService = createService(UserService.class); Call<Session> call = userService

RX JAVA + Retrofit sdk generation using Swagger codegen

江枫思渺然 提交于 2019-11-30 04:37:23
问题 I want to generate sdk using swagger codegen which can give me generated sdk with Observable as callback like below : @POST("oauth/token") Observable < TokenResponse> getRepository(@Query("grant_type") String grantType); 回答1: You can generate a Java Retrofit API client with RxJava enabled using the following command as an example: java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ -l java -i http://petstore.swagger.io/v2/swagger.json \ -c /var/tmp/retrofit2rx/java

Internet check, where to place when using MVP, RX and Retrofit

我只是一个虾纸丫 提交于 2019-11-30 04:11:59
I have went through this and this post. So I really agree with the second post that presenter should not be aware of android specific thing. So what I am thinking is putting internet check in service layer. I am using Rx Java for making network calls, so I can either place the network check before making a service call, so this way I need to manually throw and IOException because I need to show an error page on view when network is not available, the other option is I create my own error class for no internet Observable<PaginationResponse<Notification>> response = Observable.create(new

Retrofit @body with @multipart having Issue

╄→尐↘猪︶ㄣ 提交于 2019-11-30 04:01:27
Image Multipart in class type object. case 1. (Which I had done) Service params: {"id":"1","name":"vishal","image/file":""} At that time my API of Retrofit @Multipart @POST("webservice") Call<SignUpResp> loadSignupMultipart(@Part("description") RequestBody description, @Part MultipartBody.Part file, @QueryMap HashMap<String, String> params); case 2. (Where I have Problem) with @Body class<UploadwithImage> { "methodName":"submitLevel1Part2Icon", "userid":"150", "headerData":{ "fiction":{ "icon_type":"1", "icon_id":"3"}, "nonfiction":{ "icon_type":"2", "icon_id":"4"}, "relation":{ "icon_type":"3

Retrofit 2: responseBodyConverter converts to null object

别等时光非礼了梦想. 提交于 2019-11-30 03:34:56
问题 I'm using the latest (as of now 2.0.0-beta4) version of Retrofit. When receiving 200 OK code from server, everything is working fine. But I want to deal with not OK responses too, such as code 401. So, I have to get the error response code to figure out exactly what action to do and display appropriate data: @Override public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) { if (response != null && !response.isSuccess() && response.errorBody() != null) { Converter