No Retrofit annotation found. (parameter #1)

前端 未结 14 1872
长发绾君心
长发绾君心 2020-12-09 00:50

I want get RSS code from a URL with Retrofit and if I enter url staticly in the get annotation everything is OK but with dynamic url I get an error.

My

相关标签:
14条回答
  • 2020-12-09 01:11

    (Kotlin) I solved here:

    //@FormUrlEncoded // Don't used
    @POST("orders")
    fun saveOrders(@Body orders: Orders): Call<OrdersResponse>
    
    0 讨论(0)
  • 2020-12-09 01:15

    It's way too late, but i just faced the same issue. I was using retrofit 2.5.0 with 'deferred' and 'await' on my retrofit interface and viewModel. And I read from retrofit github that from 2.6.0 deferred is deprecated and we can switch from deferred to 'suspend'. before i moved my retrofit version up, i just simply changed from deferred to suspend and run it, and got the same error. I solved it by moving my retrofit version from 2.5.0 to 2.6.0.

    My point is that maybe there may be a chance that current retrofit version in your app doesn't support the way you use retrofit in your retrofit related classes or interfaces.

    0 讨论(0)
  • 2020-12-09 01:16

    My problem was that I am using Kotlin coroutines and used 'suspend' in the Retrofit GET method. Just remove it and everything works fine.

    0 讨论(0)
  • 2020-12-09 01:19

    I had the @Post annotation but forgot the @Field and @FormUrlEncoded annotations

    0 讨论(0)
  • 2020-12-09 01:20

    My problem was that I had the @POST annotation, but forgot the @Body annotation for the parameter.

    0 讨论(0)
  • 2020-12-09 01:20

    You probably forgot to initialise adapter first, as mentioned in retrofit api:

    RestAdapter restAdapter = new RestAdapter.Builder()
    .setEndpoint("https://api.github.com")
    .build();
    GitHubService service = restAdapter.create(GitHubService.class);
    

    http://square.github.io/retrofit/

    0 讨论(0)
提交回复
热议问题