I am trying to use a custom converter for Retrofit
RestAdapter.Builder builder = new RestAdapter.Builder() .setEndpoint(BuildConfig.BASE_SERVER_ENDPOINT) .setClient(new OkClient(client)).setConverter(new CitationResponseConverter()) .setLogLevel(RestAdapter.LogLevel.FULL);
below is my custom converter
public class CitationResponseConverter implements Converter { @Override public Object fromBody(TypedInput typedInput, Type type) throws ConversionException { try { InputStream in = typedInput.in();
I get the following error
retrofit.RetrofitError: method POST must have a request body.
when trying to make this api call
@POST("/service/citations") Observable<CitationMain> getCitations(@Body CitationRequestBody body);
I believe that the converter overrides the api call request, how can I avoid this and pass the request body defined in the retrofit service.
Answer:
{ "citations": [ { "coverdatestart": "2015-05-01", "coverimage": [ "09699961/S0969996115X00040/cov200h.gif", "09699961/S0969996115X00040/cov150h.gif" ], "pubyear": "2015", "refimage": [ "09699961/S0969996115X00040/S0969996115000522/gr1-t.gif", "09699961/S0969996115X00040/S0969996115000522/gr1.jpg" ], "volissue": "Volume 77", "volume": "77" }, { "pubdatetxt": "19700101", "refimage": "mma:otto_4_9781455748600/9781455748600_0020", } ] }
json android gson parsing retrofit
3xplore
source share