retrofit2

My ProgressDialog is Not Disappearing

南楼画角 提交于 2019-12-25 17:52:09
问题 I am working on a project in android to upload a file to server using file chooser But there is a problem, when i am Uploading more than 500 kB file. The file is uploaded but My Progress Dialog is not disappearing and if i uploaded file 100 KB it's uploaded to server and i got a message file uploaded successfully. But I'm not able to get server response if i uploaded more than 500 kB file. Please Help me. Thank You. It's my UploadFile() Methods private void uploadFile() { dialog =

Retrofit and Gson: parsing array/element-polymorphic objects

╄→гoц情女王★ 提交于 2019-12-25 17:17:45
问题 I am getting response in a sequence: "parameters": { "parameter": { "Data":"value" } }, "parameters":{ "parameter": [ { "Data":"value" }, { "Data":"value" }, ] }, Getting the error if I call List<Class> parameter: Expected BEGIN_OBJECT but getting BEGIN_ARRAY I need to parse parameter to get values public class ApiClient { public static final String BASE_URL ="http://........."; private static Retrofit retrofit = null; public static Retrofit getClient() { OkHttpClient client = new

Retrofit 2.0 parse dynamic json from same POJO class

倖福魔咒の 提交于 2019-12-25 16:42:13
问题 What I Have I have a server success response { "response_code": 200, "status": "success", "message": "enqiry chat fetched successfully", "meta_data": { "count": "6" }, "data": { "enquiries": [ ] } } When Error , the same API returns { "response_code": 500, "status": "error", "meta_data": { "count": 0 }, "data": [], "message": "Please specify all required parameter to add enquiries" } What happened At error scenario the data is changed from JsonObject to JsonArray My Problem At success

When i use Retrofit2.0 with POST , body is null , but the reponse code is 5xx?

China☆狼群 提交于 2019-12-25 08:26:11
问题 Gson gson = new Gson(); String json = gson.toJson(account); System.out.println(json); RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json); p2PApi.createDepositAcct(body).enqueue(new Callback<Create>() { @Override public void onResponse(Call<Create> call, Response<Create> response) { try { System.out.println(response.code()); System.out.println(response.errorBody().string()); } catch (Exception e) { e.printStackTrace(); } } @Override public void

Retrofit in android?

僤鯓⒐⒋嵵緔 提交于 2019-12-25 07:59:48
问题 I'm new to Retrofit. How can I send param and get Json from bellow url ? http://xxx:8087/courier.svc/login?username=jim&password=123456 I need to a link for tutorial . This code is in my MainActivity : private void loadJSON(String username, String password) { Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://192.168.8.11:8087/sample.svc/") .addConverterFactory(GsonConverterFactory.create()) .build(); RequestInterface_Login request = retrofit.create(RequestInterface_Login.class);

javax.net.ssl.SSLPeerUnverifiedException Error in retrieving Session key from Skyscanner API - Android

谁说胖子不能爱 提交于 2019-12-25 07:59:44
问题 I have been working on Sky scanner API to retrieve the flight fares and other details in android. I'm using the Retrofit2 for network calls. The problem is getting error in retrieving the Session key Error javax.net.ssl.SSLPeerUnverifiedException: Hostname partners.api.skyscanner.net not verified:certificate: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=DN:CN=api.skyscanner.net,OU=Infrastructure,O=Skyscanner Ltd,L=London,ST=London,C=GB APIClient public static Retrofit getRetrofit() { if

Android Retrofit 2 file upload

我的梦境 提交于 2019-12-25 07:08:21
问题 I'm using Retrofit 2 and I want to call a web service to upload my images to my server. Server side i'm using Phalcon PHP and I check if I have a file to upload. But I have never a file to upload. I can get the description parameter but not the file parameter. Could you tell me if my android code is ok ? I don't know what is wrong. ApplicationService public interface ApplicationService { ... // My other web services works well @Multipart @POST("/path/to/uploadPictures") Call<ResponseBody>

Android Retrofit 2 file upload

两盒软妹~` 提交于 2019-12-25 07:07:13
问题 I'm using Retrofit 2 and I want to call a web service to upload my images to my server. Server side i'm using Phalcon PHP and I check if I have a file to upload. But I have never a file to upload. I can get the description parameter but not the file parameter. Could you tell me if my android code is ok ? I don't know what is wrong. ApplicationService public interface ApplicationService { ... // My other web services works well @Multipart @POST("/path/to/uploadPictures") Call<ResponseBody>

Get OAuth Token from Web API to android

倖福魔咒の 提交于 2019-12-25 04:46:17
问题 I'm trying to get ِِOAuth token in android from my web api. I have tested the api in Postman and it's working perfect. Screenshot for the successful call from Postman now I need to call this Api from my android app using retrofit 2 to get the token, for that I tried to use the following interface but it's not working. @FormUrlEncoded @POST("/Token") public Call<String> Token(@Field("grant_type") String grant_type, @Field("username") String username, @Field("password") String password); How

Unable to send raw json data in post api data using Retrofit 2.0

烂漫一生 提交于 2019-12-25 04:24:55
问题 Unable to send raw JSON data in POST api data using Retrofit 2.0 try { JSONObject myUserData = new JSONObject(); myUserData.put("mobile", "917023847899"); myUserData.put("displayName", "Deepuu"); myUserData.put("info", "AD"); myUserData.put("photo", ""); myUserData.put("displayName", "Deepu"); JSONObject deviceData = new JSONObject(); ; deviceData.put("deviceId", "2124578910556991"); deviceData.put("pnToken", "klklklkl"); deviceData.put("os", "android"); deviceData.put("targetTopic",