如何解决“未找到 Retrofit 注释。(参数 #2)”?

Nik*_*aus 0 android retrofit2

我想发送一个 HTTP post 请求,到目前为止一切都很好(我在这个应用程序中发送了 10 多个请求),但现在出现了问题。

我收到此错误:

E/AndroidRuntime: FATAL EXCEPTION: main
  Caused by: java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #2)
Run Code Online (Sandbox Code Playgroud)

这是接口代码:

@POST("index.php/web/request")
    Call<MyResponse> getMy(@Header("authorization") String token, MyRequest myRequest);
Run Code Online (Sandbox Code Playgroud)

这是我的 MainActivity 代码:

Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://link.com/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        service = retrofit.create(MyAPI.class);

        MyRequest myRequest = new MyRequest();

        myRequest.setText(text);

        final Call<MyResponse> myResponseCall = service.getMy(token, myRequest);

Run Code Online (Sandbox Code Playgroud)

错误在这一行:

final Call<MyResponse> myResponseCall = service.getMy(token, myRequest);
Run Code Online (Sandbox Code Playgroud)

Kus*_*han 5

您还没有注释第二个参数....它可以是@Body,@Query等...添加注释