How to get error response from retrofit android - java

By This code, I am not able to get the error response as if I use same email id twice then I am getting the error response in postman but in my application, I am not getting the error response
So can you please help me to get out of this
My Interface
public interface SignupAPI {
#FormUrlEncoded
#POST("users")
Call<ResponseBody> createUser(
#Field("email") String email,
#Field("password") String password,
#Field("role") String role
);
}
My Java Code
public class SignupClient {
private static final String BASE_URL = "http://74.207.233.160/api/v1/";
private static SignupClient mInstance;
private Retrofit retrofit;
private SignupClient(){
retrofit = new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create()).build();
}
public static synchronized SignupClient getmInstance(){
if (mInstance == null){
mInstance = new SignupClient();
}
return mInstance;
}
public SignupAPI getApi(){
return retrofit.create(SignupAPI.class);
}
}
My Activity
Call<ResponseBody> call = SignupClient.getmInstance().getApi().createUser(email, password,role);
call.enqueue(new Callback<ResponseBody>()
{
#Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response)
{
if (response.isSuccessful()){
progressBar.setVisibility(View.GONE);
Toast.makeText(SignupActivity.this, "Account Sucessfully Created", Toast.LENGTH_SHORT).show();
}else {
try {
progressBar.setVisibility(View.GONE);
JSONObject jsonError = new
JSONObject(response.errorBody().string());
Toast.makeText(SignupActivity.this, jsonError.getString("errors"),Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
progressBar.setVisibility(View.GONE);
e.printStackTrace();
} catch (IOException e) {
progressBar.setVisibility(View.GONE);
e.printStackTrace();
}
}
}
#Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Toast.makeText(SignupActivity.this, t.getMessage(), Toast.LENGTH_SHORT).show();
}

make error pojo class..
public class Errors{
#SerializedName("email")
private List<String> email;
public void setEmail(List<String> email){
this.email = email;
}
public List<String> getEmail(){
return email;
}
}
make changes into response body class..
public class ResponseBody {
#SerializedName("errors")
private Errors errors;
public void setErrors(Errors errors){
this.errors = errors;
}
public Errors getErrors(){
return errors;
}
}
then after used into api response like
Errors errors=response.body().getErrors();

Related

volley return null response when status code is 400

I'm trying to post data to API in android which it's successful in postman with this body raw:
{
"phonenumber": "12345",
"username": "test",
"password": "1234",
"roles": 1
}
The response in successful is:
{
"message": "Registered successfully!"
}
And the response in error is:
{
"message": "Failed! this user already registered!"
}
So in android, I tried first the retrofit library and the post works perfectly if the user that I tried to register does not exist and I get the response correct
but if the user exist so the response return null 400 status code
So I tried to do it using volley in order to solve the problem but got the same result
This is my code:
private void userSignUp(){
//defining a progress dialog to show while signing up
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Signing Up...");
progressDialog.show();
String phonenumber = editTextPhonenumber.getText().toString().trim();
String username = editTextUsername.getText().toString().trim();
String password = editTextPassword.getText().toString().trim();
// url to post our data
String url = "http://xxxx/api/auth/signup";
// creating a new variable for our request queue
RequestQueue queue = Volley.newRequestQueue(SignUpActivity.this);
JSONObject object = new JSONObject();
try {
//input your API parameters
object.put("phonenumber", phonenumber);
object.put("username", username);
object.put("password", password);
object.put("roles", 1);
} catch (JSONException e) {
e.printStackTrace();
}
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, object,
new com.android.volley.Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
Toast.makeText(getApplicationContext(), "String Response : "+ response.toString(), Toast.LENGTH_LONG).show();
}
}, new com.android.volley.Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), "String Response : "+ error.networkResponse.statusCode + "\nResponse Data " + error.networkResponse.data
+ "\nCause " + error.getCause()
+ "\nmessage" + error.getMessage(), Toast.LENGTH_LONG).show();
}
}){
#Override
public String getBodyContentType() {
return "application/json";
}
};
queue.add(jsonObjectRequest);
}
And this is the retrofit version:
private void userSignUp(){
//defining a progress dialog to show while signing up
final ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Signing Up...");
progressDialog.show();
String phonenumber = editTextPhonenumber.getText().toString().trim();
String username = editTextUsername.getText().toString().trim();
String password = editTextPassword.getText().toString().trim();
//building retrofit object
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(APIUrl.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
//Defining retrofit api service
APIService service = retrofit.create(APIService.class);
//Defining the user object as we need to pass it with the call
User user = new User(phonenumber, username, password, 1);
//defining the call
Call<Result> call = service.createUser(user);
//calling the api
call.enqueue(new Callback<Result>() {
#Override
public void onResponse(Call<Result> call, Response<Result> response) {
//hiding progress dialog
progressDialog.dismiss();
if(response.isSuccessful()) {
Log.d("TAG", "onResponse: " + response.body() + " " + response.errorBody());
}
//displaying the message from the response as toast
Toast.makeText(getApplicationContext(), response.body().getMessage(), Toast.LENGTH_LONG).show();
//if there is no error
if (response.body().getMessage() == "User was registered successfully!") {
Toast.makeText(getApplicationContext(), "response.body().getMessage()", Toast.LENGTH_LONG).show();
//starting profile activity
finish();
SharedPrefManager.getInstance(getApplicationContext()).userLogin(user);
startActivity(new Intent(getApplicationContext(), MainActivity.class));
}
else {
}
}
#Override
public void onFailure(Call<Result> call, Throwable t) {
progressDialog.dismiss();
Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_LONG).show();
}
});
With it's apiservice:
public interface APIService {
//The register call
#POST("auth/signup")
Call<Result> createUser(#Body User user);
}
Request pojo:
public class User {
#SerializedName("id")
private int id;
#SerializedName("phonenumber")
private String phonenumber;
#SerializedName("username")
private String username;
#SerializedName("password")
private String password;
#SerializedName("roles")
private int roles;
public User(String phonenumber, String username, String password, int roles) {
this.phonenumber = phonenumber;
this.username = username;
this.password = password;
this.roles = roles;
}
public User(int id, String phonenumber, String username, int roles){
this.id = id;
this.phonenumber = phonenumber;
this.username = username;
this.roles = roles;
}
public User(int id, String phonenumber, String username, String password, int roles) {
this.id = id;
this.phonenumber = phonenumber;
this.username = username;
this.password = password;
this.roles = roles;
}
public int getId() {
return id;
}
public String getPhonenumber() {
return phonenumber;
}
public String getUsername() {
return username;
}
public String getPassword(){
return password;
}
public int getRoles() {
return roles;
}
}
Response pojo:
public class Result {
#SerializedName("message")
private String message;
public Result(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
Anyone can help me please? why I get this error if the user already registered?
How Can I display the error {"message": "Failed! this user already registered!"} itself just like the success response?
Actually the status code "400" is not an error code and because of that, you can create handling for that. I don't know if it'll work for you but as per your post, I think it's just the way you handle the response. Hope It'll help you :D
For example :
call.enqueue(new Callback<Result>() {
#Override
public void onResponse(Call<Result> call, retrofit2.Response<Result> response) {
mProgressDialog.dismiss();
if (response.isSuccessful()){
try {
if(response.body()!=null) {
Toast.makeText(SignUpActivity.this, "Welcome to our Apps", Toast.LENGTH_LONG).show();
} else if (response.errorBody() != null && response.code() == 400){
Toast.makeText(SignUpActivity.this, response.body(), Toast.LENGTH_LONG).show();
} else {
// If you want to add other handler
}
}catch (Exception e){
e.printStackTrace();
}
} else {
showCustomDialog2(response.errorBody().toString());
Toast.makeText(SignUpActivity.this, response.errorBody().toString(), Toast.LENGTH_LONG).show();
}
}
#Override
public void onFailure(Call<Result> call, Throwable t) {
Log.e("ERROR : ", t.getMessage());
mProgressDialog.dismiss();
}
});
But, if you have access to editing the server-side, I suggest you add a new field for the status code so that it'll make your app easier to check your user data so that your response JSON will look like this :
{
"status": "400",
"message": "Failed to sign up, user already exist !!"
}

response.body().getResponseCode()==200 - no response

the response is always raised ie Invalid response from server.
I've tried various ways but there was no response.and when I tried getCode 200 what happened was NPE
Before I used the same method with a different case I could get a response ... but in this case I didn't pay attention to the reposn. while the input and backend are correct in my opinion.
I hope my friends can help me, thank you
this function getresponse post.
HashMap<String, String> params = new HashMap<>();
params.put("id_member",sharedPrefManager.getSpIdMember() );
params.put("id_product_category", txt_id_product_category.getText().toString());
params.put("id_product", txt_id.getText().toString());
params.put("number", txt_number.getText().toString());
params.put("list_id_company", mitraStringBuilder.toString());
Call<ResponseCicilan> getCicilan = mApiService.getCicilanProduct(params);
getCicilan.enqueue(new Callback<ResponseCicilan>() {
#Override
public void onResponse(Call<ResponseCicilan> call, Response<ResponseCicilan> response) {
if(response.body()!=null){
ResponseCicilan responseCicilan = response.body();
String content ="";
if(response.body().getResponseCode()==200){
content+= responseCicilan.getData().getProductMeta().getIdProduct();
}else {
content+=responseCicilan.getMessage();
}
Log.d("jajal", "onResponse: login res"+content);
//
// Toast.makeText(TransactionSelectMitra.this, ""+response.message(), Toast.LENGTH_LONG).show();
// Log.d("bismillah", "onResponse: fail "+response.code());
// return;
}
Log.d("bismillah", "onResponse: success"+response.code()+" "+response);
if(response.body().getResponseCode()==200){
String content="";
// _loginButton.setEnabled(false);
ResponseCicilan responseCicilan = response.body();
content += "code:"+ response.code();
content += "token:"+ responseCicilan.getData().toString();
Log.d("bismillah", "onResponse: login res"+content);
} else {
Toast.makeText(TransactionSelectMitra.this, "Invalid response from server", Toast.LENGTH_SHORT).show();
}
}
#Override
public void onFailure(Call<ResponseCicilan> call, Throwable t) {
Toast.makeText(TransactionSelectMitra.this, "Invalid response from server", Toast.LENGTH_SHORT).show();
}
});
}
this api interface
#FormUrlEncoded
#POST("ApiMobile/getDatatenor")
Call<ResponseCicilan> getCicilanProduct(#FieldMap HashMap<String, String> params);
response.java
public class ResponseCicilan{
#SerializedName("response_code")
private int responseCode;
#SerializedName("data")
private Data data;
#SerializedName("message")
private String message;
public void setResponseCode(int responseCode){
this.responseCode = responseCode;
}
public int getResponseCode(){
return responseCode;
}
public void setData(Data data){
this.data = data;
}
public Data getData(){
return data;
}
public void setMessage(String message){
this.message = message;
}
public String getMessage(){
return message;
}
}

Why I am getting JsonSyntaxException Error

I am new to retrofit (I was using volley before), before this I was doing fine with retrofit until this error comes :-
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:
Expected int but was Boolean at line 8 column 37 path
$.response.data.book_service_id
I tried with every solution provided in this site but could not help myself since I am new to retrofit.
I think it's because of the JSON parsing error. I don't know how to handle it.
This may be a duplicate question but please help.
Below is my code:
Request and fetching data:
private void makeBookingRequest(String position) {
final CustomProgressDialog dialog = new CustomProgressDialog();
dialog.show(getSupportFragmentManager(),"tag");
SharedPreferences preferences = getSharedPreferences("MYSharedPref",MODE_PRIVATE);
String sessionkey = preferences.getString("sessionkey",null);
System.out.println(sessionkey);
String serviceId = position;
System.out.println(position);
APIEndPoints endPoints = Url.getInstance().create(APIEndPoints.class);
Call<Book> call = endPoints.makeBookingRequest(serviceId,sessionkey);
call.enqueue(new Callback<Book>() {
#Override
public void onResponse(Call<Book> call, retrofit2.Response<Book> response) {
dialog.dismiss();
if (!response.isSuccessful()) {
Toast.makeText(HomeActivity.this, "server is not responding", Toast.LENGTH_SHORT).show();
}
else if(response.body() != null){
Book bookData = response.body();
String message = bookData.response.message;
Toast.makeText(HomeActivity.this, message, Toast.LENGTH_SHORT).show();
}
}
#Override
public void onFailure(Call<Book> call, Throwable t) {
dialog.dismiss();
Toast.makeText(HomeActivity.this, "Error" + t.getLocalizedMessage(),
Toast.LENGTH_SHORT).show();
System.out.println(t);
}
});
}
Model Class:
package com.medpal.medpal_client.Models;
import com.google.gson.annotations.SerializedName;
public class Book {
#SerializedName("response")
public ResponseEntity response;
public class ResponseEntity{
#SerializedName("data")
public DataEntity data;
#SerializedName("secondary_message")
public String secondary_message;
#SerializedName("message")
public String message;
#SerializedName("code")
public int code;
}
public class DataEntity {
#SerializedName("book_service_id")
public int book_service_id;
}
}
APIENDPOINTS
#FormUrlEncoded
#Headers({"apikey: testapikey", "Content-Type:application/x-www-form-urlencoded" })
#POST("service/accept?")
Call<Book> makeBookingRequest(
#Field("service_id") String ServiceId,
#Field("session_key") String sessionKey);
URL class
public class Url {
public static final String base_url = "http://www.medpal.net/api/v1/";
public static final String serviceUrl = "http://www.medpal.net/api/v1/services?";
public static Retrofit retrofit;
public static Retrofit getInstance() {
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(base_url)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit;
}
}
Finallyy Response from server:
{
"response": {
"error": [],
"code": 200,
"message": "Service booked",
"secondary_message": "Service booked successfully",
"data": {
"book_service_id": 35
}
}
}
To detect the problem exactly, You need to use an interceptor to log the server response, to log the server responses you can use OkHttp3 here is an example of it.
private OkHttpClient provideOkhttpClient() {
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.readTimeout(15000, TimeUnit.MILLISECONDS);
client.writeTimeout(70000, TimeUnit.MILLISECONDS);
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
client.addInterceptor(interceptor);
return client.build();
}
And add this to your Retrofit.Builder
.client(provideOkhttpClient())
And these are for Gradle
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0'
If you do this you will see everything you sent and got from the server at your Logcat.

Api work with Postman but not in android application

A method build in Java using Jersey which takes two parameters and store in database it works properly with the postman but when I use it in Android Application it not work. I try to send a request using Volley and Retrofit.
Server Side Code:
#POST
#Produces(MediaType.APPLICATION_JSON)
#Path("/register")
public Boolean registerUser(#FormParam("userName") String userName, #FormParam("password") String password) {
System.out.println(userName+"\t"+password);
String insertQuery = "INSERT INTO user(user_name,password,status) VALUES(?,?,?)";
try {
Connection con = MyConnection.getConnection();
PreparedStatement prst = con.prepareStatement(insertQuery);
prst.setString(1, userName);
prst.setString(2, password);
prst.setInt(3, 0);
int count = prst.executeUpdate();
con.close();
System.out.println(count+" Row inserted");
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}
Android Code :
public void register(final String userName, final String password) {
User user = new User(userName, password, 1);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://192.168.1.13:8080/Demo_Application/")
.addConverterFactory(GsonConverterFactory.create())
.build();
JsonPlaceholderApi jsonPlaceholderApi = retrofit.create(JsonPlaceholderApi.class);
Call<List<User>> call = jsonPlaceholderApi.register("application/x-www-form-urlencoded", user);
call.enqueue(new Callback<List<User>>() {
#Override
public void onResponse(Call<List<User>> call, Response<List<User>> response) {
if (!response.isSuccessful()){
Log.e("Response","Something went wrong."+response.toString());
return;
}
Log.d("Response",response.toString());
}
#Override
public void onFailure(Call<List<User>> call, Throwable t) {
Log.e("Response",t.getMessage());
}
});
}
Postman Response
Volley Request:
public void registerVolley(final String userName, final String password){
Map<String, String> param = new HashMap<>();
param.put("userName", userName);
param.put("password",password);
JsonObjectRequest arrayRequest = new JsonObjectRequest(Request.Method.POST, "http://192.168.0.26:8080/Demo_Application/rs/test/register", new JSONObject(param), new com.android.volley.Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
Log.e("Response", response.toString());
}
}, new com.android.volley.Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.e("Response", error.toString());
}
}){
#Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> param = new HashMap<>();
param.put("userName", userName);
param.put("password",password);
return param;
}
#Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> header = new HashMap<>();
header.put("Content-Type","application/json");
return header;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(arrayRequest);
}
Your code for retrofit:
JsonPlaceholderApi jsonPlaceholderApi = retrofit.create(JsonPlaceholderApi.class);
Call<Boolean> call = jsonPlaceholderApi.sign("userName", "password");
call.enqueue(new Callback<Boolean>() {
#Override
public void onResponse(Call<Boolean> call, Response<Boolean> response) {
if (!response.isSuccessful()){
Log.e("Response","Something went wrong."+response.toString());
return;
}
Log.d("Response",response.toString());
}
#Override
public void onFailure(Call<Boolean> call, Throwable t) {
Log.e("Response",t.getMessage());
}
});
Your method inside jsonPlaceholderApi :
#FormUrlEncoded
#POST("rs/test/register")
Call<ResponseLogin> signIn(
#Field("userName") String userName,
#Field("password") String password
);
Add Below Code in proguard-rules.pro
-keepattributes *Annotation*
-keepclassmembers class ** {
#org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
-keep class com.app.appname.model.** { *; }
NOTE: Change last line with your model folder

How to fix Expected BEGIN_OBJECT but was STRING in Retrofit? [duplicate]

This question already has an answer here:
How to fix Expected BEGIN_OBJECT in Retrofit?
(1 answer)
Closed 4 years ago.
In my application i want use Retrofit for get some data from server.
I write below codes but when run application and call api show me below error :
E/socketLogResponse: Err : com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
Please see my above codes and help me
API response from server :
{
"status": "ok",
"time": 0.014972925186157227
}
ApiService interface :
#POST("api/log")
Call<SocketPingResponse> getSocketPingLog(#Header("jwt") String jwt, #Body SocketPingBodySendData socketPingBodySendData);
SocketPingResponse class :
public class SocketPingResponse {
#SerializedName("status")
#Expose
private String status;
#SerializedName("time")
#Expose
private Double time;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Double getTime() {
return time;
}
public void setTime(Double time) {
this.time = time;
}
}
SocketPingBodySendData class :
public class SocketPingBodySendData {
#SerializedName("auction_id")
#Expose
int auction_id;
#SerializedName("data")
#Expose
List<SocketPingEntity> data;
public int getAuction_id() {
return auction_id;
}
public void setAuction_id(int auction_id) {
this.auction_id = auction_id;
}
public List<SocketPingEntity> getData() {
return data;
}
public void setData(List<SocketPingEntity> data) {
this.data = data;
}
}
Api call codes in activity :
pingEntityList.addAll(socketPingDatabase.socketPingDao().getSocketPingEntityList());
SocketPingBodySendData pingBodySendData = new SocketPingBodySendData();
pingBodySendData.setAuction_id(auctionID);
pingBodySendData.setData(pingEntityList);
Toast.makeText(context, ""+pingEntityList.size(), Toast.LENGTH_SHORT).show();
Call<SocketPingResponse> pingResponseCall = apis.getSocketPingLog(jwtToken, pingBodySendData);
pingResponseCall.enqueue(new Callback<SocketPingResponse>() {
#Override
public void onResponse(Call<SocketPingResponse> call, Response<SocketPingResponse> response) {
if (response.body() != null) {
Toast.makeText(context, response.body().getStatus(), Toast.LENGTH_SHORT).show();
if (response.body().getStatus().equals("ok")) {
pingEntityList.clear();
socketPingDatabase.socketPingDao().deleteAll();
}
}
}
#Override
public void onFailure(Call<SocketPingResponse> call, Throwable t) {
Log.e("socketLogResponse", "Err : " + t.toString());
}
});
ApiClient class :
public class ApiClient {
private static final String BASE_URL = Constants.SERVER;
private static Retrofit retrofit = null;
private static Context context;
public static Retrofit getClient() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.interceptors().add(interceptor);
client.addInterceptor(new Interceptor() {
#Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request().newBuilder().addHeader("X-Client-Version", Constants.getAppVersionName()).build();
return chain.proceed(request);
}
});
client.addInterceptor(new Interceptor() {
#Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request().newBuilder().addHeader("uuid", Constants.getUUID(Constants.currentActivity)).build();
return chain.proceed(request);
}
});
client.addInterceptor(new Interceptor() {
#Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request().newBuilder().addHeader("agent", Constants.getAgent()).build();
return chain.proceed(request);
}
});
OkHttpClient client2 = client
.connectTimeout(60, TimeUnit.SECONDS)
.writeTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.build();
Gson gson = new GsonBuilder()
.setLenient()
.create();
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.client(client2)
.build();
}
return retrofit;
}
}
How can i fix this issue?
I think the problem returns string when no data is returned. Backend can usually do such errors. this error had happened to me before. you should check the response json when no data is available
Retrofit is typesafe library. It means that it waits only particular (predefined) types of objects. If server sends something else - it crashes with error. This is your case. Just check raw server response and you'll see what's wrong.
Try changing your API call
from
#POST("api/log")
Call<SocketPingResponse> getSocketPingLog(#Header("jwt") String jwt, #Body SocketPingBodySendData socketPingBodySendData);
to
#POST("api/log")
Call<String> getSocketPingLog(#Header("jwt") String jwt, #Body SocketPingBodySendData socketPingBodySendData);
pingEntityList.addAll(socketPingDatabase.socketPingDao().getSocketPingEntityList());
SocketPingBodySendData pingBodySendData = new SocketPingBodySendData();
pingBodySendData.setAuction_id(auctionID);
pingBodySendData.setData(pingEntityList);
Toast.makeText(context, ""+pingEntityList.size(), Toast.LENGTH_SHORT).show();
Call<String> pingResponseCall = apis.getSocketPingLog(jwtToken, pingBodySendData);
pingResponseCall.enqueue(new Callback<String>() {
#Override
public void onResponse(Call<String> call, Response<String> response) {
if (response.body() != null) {
//Convert here your string response to Other POJO format
}
}
#Override
public void onFailure(Call<String> call, Throwable t) {
Log.e("socketLogResponse", "Err : " + t.toString());
}
});

Categories

Resources