Anyone faced this issue, where api response is no...
# announcements
r
Anyone faced this issue, where api response is not static but dynamic, like in case of 200 it will give full json response body and in case of 304 empty body and then there moshi throws exception. If anyone dealt with it before, I know we can write convertor but is there any other way.
k
304 means
Not Modified
. So either you could remove the
If-Modified-Since
header which might be present or you have to cache the data.
t
without knowing what frameworks you’re using it’s hard to be concrete, but if you’re using codegen it should handle it for you. If you’re writing your own code you need to introspect the status code before deserializing
r
@Kroppeb Yeah the whole idea is to cache it, as the status code signifies not modified. And in case of 304 since the api response is without any body, moshi throws exception, as it's not able to serialize it to the pojo given to the retrofit for 200. I was more hoping it to serialize it give me the object.
@tddmonkey It's android.
code you need to introspect the status code before deserializing
Yeah, i am thinking of doing as a last solution.
t
You might have better luck posting in the #C0B8M7BUY channel then