Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use RetroFit2 responseBodyConverter in Kotlin?

I'm trying to use RetroFit's responseBodyConverter() but I'm having some trouble, I'm expected to pass java.lang.annoatation.annoatation as the second parameter, but Kotlin suggests against that and says to use Kotlin.Annotation. I'm unsure of how to do that. Can someone provide an example of responseBodyConverter() in Kotlin?

like image 262
nland Avatar asked Nov 03 '17 13:11

nland


People also ask

Can we use retrofit in Kotlin?

Retrofit is a type-safe REST client for Android, Java and Kotlin developed by Square. The library provides a powerful framework for authenticating and interacting with APIs and sending network requests with OkHttp. See this guide to understand how OkHttp works.

What is kotlin retrofit?

Kotlin and retrofit network call tutorial What is retrofit. This is a rest client library for java and android. This means that we. use retrofit to make network calls from our applications. In android applications, Retrofit makes use of OkHttp which is a low level.


1 Answers

@bluecup in the AndroidChat slack channel has led me to the correct answer. I ended up doing the following:

Retrofit.responseBodyConverter(<T>, arrayOfNulls<Annotation>(0))

Hope this helps someone else.

like image 130
nland Avatar answered Sep 20 '22 14:09

nland