Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android “如何修复”;未找到改装注释。(参数“2”)是什么;?_Android_Retrofit2 - Fatal编程技术网

Android “如何修复”;未找到改装注释。(参数“2”)是什么;?

Android “如何修复”;未找到改装注释。(参数“2”)是什么;?,android,retrofit2,Android,Retrofit2,我想发送一个HTTPPOST请求,到目前为止一切都很好(我在这个应用程序中发送了10多个请求),但现在出现了一个问题 我得到这个错误: E/AndroidRuntime: FATAL EXCEPTION: main Caused by: java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #2) 这是接口代码: @POST("index.php/web/request") Call

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

我得到这个错误:

E/AndroidRuntime: FATAL EXCEPTION: main
  Caused by: java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #2)
这是接口代码:

@POST("index.php/web/request")
    Call<MyResponse> getMy(@Header("authorization") String token, MyRequest myRequest);
@POST(“index.php/web/request”)
调用getMy(@Header(“authorization”)字符串令牌,MyRequest MyRequest);
这是我的主要活动代码:

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);

reformation-reformation=new-reformation.Builder()
.baseUrl(“https://link.com/")
.addConverterFactory(GsonConverterFactory.create())
.build();
服务=改装.create(MyAPI.class);
MyRequest MyRequest=新建MyRequest();
myRequest.setText(文本);
最终调用myResponseCall=service.getMy(令牌,myRequest);
错误在这一行:

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

将您的接口方法更改为

@FormUrlEncoded
@POST("index.php/web/request")
    Call<MyResponse> getMy(@Header("authorization") String token);
@FormUrlEncoded
@POST(“index.php/web/request”)
调用getMy(@Header(“authorization”)字符串令牌);

@FormUrlEncoded
@POST(“index.php/web/request”)
调用getMy(@Header(“authorization”)字符串令牌,MyRequest MyRequest);

将您的接口方法更改为

@FormUrlEncoded
@POST("index.php/web/request")
    Call<MyResponse> getMy(@Header("authorization") String token);
@FormUrlEncoded
@POST(“index.php/web/request”)
调用getMy(@Header(“authorization”)字符串令牌);

@FormUrlEncoded
@POST(“index.php/web/request”)
调用getMy(@Header(“authorization”)字符串令牌,MyRequest MyRequest);

您尚未注释第二个参数。。。。可以是@Body、@Query等。。。。添加注释

您尚未注释第二个参数。。。。可以是@Body、@Query等。。。。添加注释

@DeepakS.Gavkar自上次请求以来,我没有更改任何内容,我不知道您的确切想法……您没有注释第二个参数。。。。可以是@Body、@Query等。。。。添加annotation@Kushan就这样,谢谢!太好了,把它作为一个answer@DeepakS.Gavkar自上次请求以来,我没有更改任何内容,我不知道您的确切想法…您没有注释第二个参数。。。。可以是@Body、@Query等。。。。添加annotation@Kushan就这样,谢谢!太好了,我补充道