I have a HATEOAS (HAL) REST service and managed to talk to it with the code below (using halarious as a conversion engine) but when I try to merge the converters (stal
In my case I needed to serialize and deserialize only one class to XML. For everything else I needed Json. So I registered my adapters like this:
retrofit = new Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.addConverterFactory(EditUserXmlConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(createGson()))
.client(httpClient.build())
.build();
since I could not extend SimpleXmlConverterFactory
(unfortunately) I had to use my own class and change the following line:
if (!(type instanceof Class)) return null;
to
if (type != NeedToBeXML.class) return null;
This way only responses and requests of type NeedToBeXML
are converted to XML - and everything else JSON.