retrofit - How do you specify that an API method has no response body? -
i trying use retrofit 2.0 , converter-jackson module consume api.
i have few methods status of objects , converting received payload objects works fine.
i have endpoint need put in order acknowledge have processed objects returned request. put method not return body, status of 200 if works or appropriate error code.
i have tried few different ways specify put method in retrofit interface no success. error this:
com.fasterxml.jackson.databind.jsonmappingexception: no content map due end-of-input @ [source: java.io.inputstreamreader@1d5ef9ae; line: 1, column: 1] if specify return type of method object don't expect receive, this:
@put('/acknowledgestatus') call<string> acknowledgestatus(@body acknowledgement idstoacknowledge) and errors this:
java.lang.illegalargumentexception: not locate call adapter class com.example.myobject. tried: * retrofit.defaultcalladapter$1 where myobject object returned 1 of retrofit api's other methods when try define put method either of these:
@put('/acknowledgestatus') call acknowledgestatus(@body acknowledgement idstoacknowledge) @put('/acknowledgestatus') response acknowledgestatus(@body acknowledgement idstoacknowledge) how can tell retrofit not expect response body method , still have access response status, headers , other details?
update: of second beta release, can use return type of void
@put('/acknowledgestatus') call<void> acknowledgestatus(@body acknowledgement idstoacknowledge) the following still works, might less efficient --
try telling want responsebody.
@put('/acknowledgestatus') call<responsebody> acknowledgestatus(@body acknowledgement idstoacknowledge) that give access response status, etc, , raw response body (if any).
Comments
Post a Comment