1

I have an issue with load XML feed from url using Retrofit.

Given a dynamic url that clearly returns xml feed f.e: https://anchor.fm/s/53faae8/podcast/rss

When I try to load this via Retrofit I can see in Android Studio Network Profilier that it returns a scrambled response. Something like this:

ì½ÝvÜF’.z=ó­5mÏ&d&€ÛmÊ’Ûš¶-K=š>{íµWH°`Ve EšsÕ÷çö¬5ûö
<X?ɉˆLüT‰jIUîÖL·šUäoDFdü|ñÙ?¯–Þ•iÚ²®~÷$8õŸx¦Ê꼬.~÷ä�o¾bêÉŸÖ´­VíYžýîÉ¢ëÖgOŸ®7Íò´n.žæÙS³4+SuíÓà4xúÄ=›ÕU_¾û4úOWu¾Yšö©{pxQwõjxëúúúôZÐ{Ü÷ççðã“qȇl_+»MeÚ­

Etc.

I've added an xml converter in my retrofitBuilder:

retrofitBuilder.addConverterFactory(SimpleXmlConverterFactory.createNonStrict(Persister(AnnotationStrategy())))

And my service code to retrieve the xml from url looks like: interface XmlFeedService {

@GET 
fun getXmlFeedFromUrl(@Url url: String): Call<RssFeed>

I am using @Url annotation here since the url is dynamic and depending what another api returns to me can result in urls with different base url's.

Of course the response body can't be parsed like this, but I am unclear why it comes back like this. Can anyone help out?

Rik van Velzen
  • 1,977
  • 1
  • 19
  • 37

1 Answers1

0

Figured it out already. It's not due to a wrong configuration of the Retrofit builder or the service, but the scrambled response that the Network Profiler showed me was due to the some of the Annotation in the Data models being wrongly configured...

Rik van Velzen
  • 1,977
  • 1
  • 19
  • 37