java - Android - Retrofit being received as null when the model contains a byte[] -


i'm using retrofit post data webapi rest service. however, if model contains byte[], value received webapi null. if remove property signature model received expected rest of values.

also, leaving signature property null work. it's when signature has content webapi receives null value.

the byte array contains png signature image captured on device.

here's model, containing byte[] property:

public class refunddto {     public string id;     public string amount;     public int assetid;     public string comments;     public string datecreated;     public string datemodified;     public int faultid;     public int refundactionid;     public int siteid;     public int userid;      public byte[] signature; // culprit } 

i send model using following code:

refunddto dto = getdto(); service.postrefund(dto, new callback<refunddto>() {     @override     public void success(refunddto dto, response response) {         databasehandler db = new databasehandler(context);         db.deleterefund(dto.id);         db.close();     }      @override     public void failure(retrofiterror retrofiterror) {     } }); 

my dataservice method retrofit looks this:

@post("/refunds") void postrefund(@body refunddto model, callback<refunddto> callback); 

which sending following rest method:

public class refundscontroller : apicontroller {     public refunddto post([frombody]refunddto value)     {         // value null!     } } 

i managed sort this. changed byte[] string , sent signature base64 encoded string:

dto.signature = new string(base64.encode(getsignature(), 0)); 

i left server side model using byte[] , webapi took care of conversion.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -