java - How can I access request MultipartBody information in new Callback<ResponseBody>? -


hello fellow android programmers. stuck on problem. need retrieve filename or index of loop iteration within callback method. using retrofit 2.0.

i thinking can pass information post form field (even if server doesn't need it), , retrieve in call.request.body() inside onresponse() method.

if use debugger can see data. see 2 parts of form. thinking can add part in form hold index. however, don't know how access through code. know best way this? want make sure images have been uploaded @ end of last onresponse callback.

initially wanted using call.execute.body() because have "please wait dialog" gives me exception saying should call method inside asynctask.

please ignore attempts @ turning request json object...

any ideas help, thanks!

for (file f : theimages) {     requestbody reqfile = requestbody.create(mediatype.parse("image/*"), f);     multipartbody.part body = multipartbody.part.createformdata("file", "image.jpg", reqfile);     requestbody repid = requestbody.create(mediatype.parse("text/plain"), string.valueof(newexternalreportid));     uploadcall = hazsnapapi.postimage(body, repid, 1l);     uploadcall.enqueue(new callback<responsebody>() {         @override         public void onresponse(call<responsebody> call, response<responsebody> response) {             responsebody rbody = response.body();             requestbody mrequest = call.request().body();             try {                 string temp = call.request().tostring();                 jsonobject bodyasjson = new jsonobject(call.request().tostring());             } catch (jsonexception e) {                 e.printstacktrace();             }           }         @override         public void onfailure(call<responsebody> call, throwable t) {             t.printstacktrace();          }     }); } 

i ended creating services creates retrofit call. way can call.execute.body(). works because service not run on main thread.


Comments

Popular posts from this blog

How to use SUM() in MySQL for calculated values -

loops - Spock: How to use test data with @Stepwise -