I have a problem when parsing json by using Retrofit can't get any of data , This URL request array of parameter
https://lao.busnavi.asia/api/location.php?ids%5B%5D=132&ids%5B%5D=133&ids%5B%5D=131
JSON from server that looks like this json data
My code
LatestBusLocation.java
@SerializedName("id") private int id;
@SerializedName("status") private int status;
@SerializedName("route_id") private String routeId;
@SerializedName("lng") private double lng;
@SerializedName("lat") private double lat;
@SerializedName("accuracy") private double accuracy;
@SerializedName("speed") private double speed;
@SerializedName("heading") private float heading;
@SerializedName("date") private Date date;
Interface class
public interface ApiService {
@POST("location.php")
Call<LatestBusLocation> loadLatestBusLocation(@Query("ids[]") int[] ids);
}
MainActivity.java
int[] ids = {131, 132, 133};
Call<LatestBusLocation> call = HttpManager.getInstance()
.getService().loadLatestBusLocation(ids);
call.enqueue(new Callback<LatestBusLocation>() {
@Override
public void onResponse(Call<LatestBusLocation> call, Response<LatestBusLocation> response) {
Log.e("WorkOrNote1", "Working");
if (response.isSuccessful()) {
dao = response.body();
Log.d("daoResponse", String.valueOf(dao.getId()));
} else {
try {
Log.e("LatestBusLocation", response.errorBody().string());
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void onFailure(Call<LatestBusLocation> call, Throwable t) {
Log.e("onFailure", t.toString());
}
});