How do you send byte[] array in retrofit call. I just need to send over byte[]. I get this exception when I have been trying to send a retrofit call.
retrofit.RetrofitError:?retrofit.converter.ConversionException:
com.google.gson.JsonSyntaxException:?java.lang.IllegalStateException:?
Expected?a?string?but was BEGIN_OBJECT at line?1?column?2
What is the way I can make the call using retrofit.
I was simply passing byte array as a ByteMessage encapsulated in the object class.
public class ByteMessage {
private byte[] byteArray;
byte[] getByteArray() {
return byteArray;
}
setByteArray(byte[] bytes){
byteArray = bytes;
}
}
@POST("/send")
sendBytes(ByteMesssage msg);
Server side:
sendBytes(ByteMessage msg) {
byte[] byteArray = msg.getByte();
...doSomething...
}
I could not find resources on the stack overflow or googling for a proper solution passing byte arrays through retrofit call.
Can anyone please help with this.
Thanks
Dhiren
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…