retrofit2

Retrofit Calling the Magneto API using @FormUrlEncoded getting issue while sending the data to the magneto server

淺唱寂寞╮ 提交于 2021-02-11 12:51:58
问题 override fun submitSupportTicket(createSupportTicket: MutableLiveData, question: String, details: String, department: String, filePath: String) { var getSupporttUrl = "https://xxxxxxxx/V1/ecomapi/postNewSupportTicket" if (filePath.isEmpty()) { /* var getDepartmentInput = Constants.getDefaultParameterJasonInput(Constants.getUserId()) getDepartmentInput.put("questionText",question) getDepartmentInput.put("detailText",details) getDepartmentInput.put("departmentId",department)*/ /* val requestMap

can't get ArrayList outside of for loop in call.enqueue

左心房为你撑大大i 提交于 2021-02-10 12:34:26
问题 I want to get ArrayList data out of for loop from call.enqueue method in Retrofit. how to access lists outside of call.enqueue mehtod? Everything is working fine. When printing list size I'm getting value what I want. The only problem is i can't access values from outside of call.enqueue method. private void getSchoolList() { final Call<List<DanceSchool>> call = RetrofitClient.getInstance().getApi().getDanceSchools(); call.enqueue(new Callback<List<DanceSchool>>() { @Override public void

can't get ArrayList outside of for loop in call.enqueue

三世轮回 提交于 2021-02-10 12:34:05
问题 I want to get ArrayList data out of for loop from call.enqueue method in Retrofit. how to access lists outside of call.enqueue mehtod? Everything is working fine. When printing list size I'm getting value what I want. The only problem is i can't access values from outside of call.enqueue method. private void getSchoolList() { final Call<List<DanceSchool>> call = RetrofitClient.getInstance().getApi().getDanceSchools(); call.enqueue(new Callback<List<DanceSchool>>() { @Override public void

how to send json array in android retrofit?

穿精又带淫゛_ 提交于 2021-02-10 12:12:57
问题 I can't send json array to server. When I test in postman raw, it is ok, success return. Postman Raw; [ { "product_id": 2, "name": "Umbrella", "price": 200, "quantity": 1, "totalprice": 200, "user_id": 1 }, { "product_id": 1, "name": "Apple", "price": 200, "quantity": 1, "totalprice": 200, "user_id": 1 } ] APIInterface; @POST("example/api/order") Call<JSONArray> postOrder(@Body JSONArray jsonArray); CartActivity; try { JSONArray jsonArray = new JSONArray(); for (Cart cart : cartList) {

how to send json array in android retrofit?

眉间皱痕 提交于 2021-02-10 12:12:21
问题 I can't send json array to server. When I test in postman raw, it is ok, success return. Postman Raw; [ { "product_id": 2, "name": "Umbrella", "price": 200, "quantity": 1, "totalprice": 200, "user_id": 1 }, { "product_id": 1, "name": "Apple", "price": 200, "quantity": 1, "totalprice": 200, "user_id": 1 } ] APIInterface; @POST("example/api/order") Call<JSONArray> postOrder(@Body JSONArray jsonArray); CartActivity; try { JSONArray jsonArray = new JSONArray(); for (Cart cart : cartList) {

how to send json array in android retrofit?

馋奶兔 提交于 2021-02-10 12:10:23
问题 I can't send json array to server. When I test in postman raw, it is ok, success return. Postman Raw; [ { "product_id": 2, "name": "Umbrella", "price": 200, "quantity": 1, "totalprice": 200, "user_id": 1 }, { "product_id": 1, "name": "Apple", "price": 200, "quantity": 1, "totalprice": 200, "user_id": 1 } ] APIInterface; @POST("example/api/order") Call<JSONArray> postOrder(@Body JSONArray jsonArray); CartActivity; try { JSONArray jsonArray = new JSONArray(); for (Cart cart : cartList) {

How to send FCM notification from android using Retrofit?

一世执手 提交于 2021-02-09 12:37:12
问题 I am want send fcm notification from android device to another device , using retrofit . I try this but, public interface ApiInterface { @Headers("Authorization : key=AAAA4Ubio1Q:APA91bGWkw84b1XX2nnnOKn8MO25U2giLRXXXTUkXidojFluZk_qKXXXlS27oMZZV5goTQdwRtpdmvI1iAPRZZDNKz6c-mpU6nvHZJ-Jg9f1fQ5NdttftqUpqwAkObLEEX26VFDDbXN8") @POST("fcm/send") Call<ResponseBody> sendChatNotification(@Field("to") String token,@Body RequestNotificaton requestNotificaton); } i am getting this error java.lang

How to send FCM notification from android using Retrofit?

可紊 提交于 2021-02-09 12:37:09
问题 I am want send fcm notification from android device to another device , using retrofit . I try this but, public interface ApiInterface { @Headers("Authorization : key=AAAA4Ubio1Q:APA91bGWkw84b1XX2nnnOKn8MO25U2giLRXXXTUkXidojFluZk_qKXXXlS27oMZZV5goTQdwRtpdmvI1iAPRZZDNKz6c-mpU6nvHZJ-Jg9f1fQ5NdttftqUpqwAkObLEEX26VFDDbXN8") @POST("fcm/send") Call<ResponseBody> sendChatNotification(@Field("to") String token,@Body RequestNotificaton requestNotificaton); } i am getting this error java.lang

Retrofit / OkHttp3 400 Error Body Empty

吃可爱长大的小学妹 提交于 2021-02-08 13:32:04
问题 I am using Retrofit 2 in my Android project. When I hit an API endpoint using a GET method and it returns a 400 level error I can see the error content when I use an HttpLoggingInterceptor, but when I get to the Retrofit OnResponse callback the error body's string is empty. I can see that there is a body to the error, but I can't seem to pull that body when in the context of the Retrofit callback. Is there a way to ensure the body is accessible there? Thanks, Adam Edit: The response I see

Retrofit multiple response types

為{幸葍}努か 提交于 2021-02-08 09:13:48
问题 How can I use Retrofit2 to parse these two kinds of API responses? Ok response (HTTP 200): { "data": { "foo": "bar" } } Error response (HTTP 200): { "error": { "foo": "bar" } } I've read tons of SO questions and tutorials, but I don't know how to do that, I've tried: GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(new ItemTypeAdapterFactory()); Gson gson = gsonBuilder.create(); final Retrofit retrofit = new Retrofit.Builder() .client(getOkHttpClient())