【发布时间】:2021-02-15 06:39:07
【问题描述】:
我有一个 api 请求,我需要在 url 中传递多个@Path,我这样做了,但我一直收到错误,我想就这个问题获得一些帮助,提前谢谢你
- 这是网址示例
https://api.site.dev/api/v2/entries/en_US/hello - 这是改造设置
@Singleton
@Provides
fun provideRetrofitInstance(): ApiInterface {
val httpLoggingInterceptor = HttpLoggingInterceptor()
val interceptor = httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC)
val okHttp = OkHttpClient.Builder()
.addInterceptor(interceptor)
.build()
return Retrofit.Builder()
.baseUrl("https://api.site.dev/api/v2/entries/")
.addConverterFactory(GsonConverterFactory.create())
.client(okHttp)
.build()
.create(ApiInterface::class.java)
}
- 这是我的改造电话
Error Unable to create call adapter for class com.dic.mydictionnary.models.DictionnaryModelItem
for method ApiInterface.getDictionnaryWord
*这是我的 apiInterfac
@GET("{language_code}/{word}")
fun getDictionnaryWord(
@Path("language_code") language : String,
@Path("word") word : String,
) : DictionnaryModelItem
}
【问题讨论】: