android - Retrofit 2 onResponse method not called although Http request returns data -
i making asynchronous http request, calling web service returns list of game dates in json format. can see in log data being returned, neither onresponse
nor onfailure
methods being called.
following code fragments followed log showing results of http request. note web service being called being asked return 1 column out of 30 (gamedate
) games
table. there 2 rows in table , gamedate
column being returned both rows seen in log. attempting pass game date list main activity display.
does have idea why neither onresponse
nor onfailure
methods being reached?
public interface gamesapi { @get("/hcdbwebservice/hcdbwebservice.php?format=json&operation=gamelist") call<list<game>> listgames(); } private void requestdata() { log.d("mainactivity.logtag", "requestdata method"); httplogginginterceptor interceptor = new httplogginginterceptor(); interceptor.setlevel(httplogginginterceptor.level.body); okhttpclient client = new okhttpclient.builder().addinterceptor(interceptor).build(); retrofit retrofit = new retrofit.builder() .baseurl(api_base_url) .client(client) .addconverterfactory(gsonconverterfactory.create()) .build(); gamesapi api = retrofit.create(gamesapi.class); call<list<game>> call = api.listgames(); call.enqueue(new callback<list<game>>() { @override public void onresponse(call<list<game>> call, response<list<game>> response) { if(response.issuccessful()) { gamelist = response.body(); } else { log.e("error code", string.valueof(response.code())); log.e("error body", response.errorbody().tostring()); } } @override public void onfailure(call<list<game>> call, throwable t) { log.d("error", t.getmessage()); } }); }
log output:
d/okhttp: date: thu, 22 sep 2016 13:42:54 gmt d/okhttp: server: apache/2.2.31 (unix) mod_wsgi/3.5 python/2.7.12 php/7.0.10 mod_ssl/2.2.31 openssl/1.0.2h dav/2 mod_fastcgi/2.4.6 mod_perl/2.0.9 perl/v5.24.0 d/okhttp: x-powered-by: php/7.0.10 d/okhttp: content-length: 53 d/okhttp: keep-alive: timeout=5, max=100 d/okhttp: connection: keep-alive d/okhttp: content-type: application/json d/okhttp: [{"gamedate":"2016-09-15"},{"gamedate":"2016-09-19"}] d/okhttp: <-- end http (53-byte body)
Comments
Post a Comment