改造 2 post 错误

Retrofit 2 post error

我正在使用 Retrofit2,我想 post 我们的服务器得到一些 json data.So 我有 2 classes。这是我的回复 class:

public class RegisterToken {

private String accessToken;
private String tokenType;
private Integer expiresIn;
private String refreshToken;
private String asClientId;
private String Issued;
private String Expires;
private Map<String, Object> additionalProperties = new HashMap<>();

public String getAccessToken() {
    return accessToken;
}

public void setAccessToken(String accessToken) {
    this.accessToken = accessToken;
}

//and the other setter and getter,actually dont write cuz its too long

}

然后这是我的 API post 界面:

public interface APIService {
@FormUrlEncoded
@POST("token")
public Callback<RegisterToken>  getRegisterToken(@Header("Accept")String accept,
    @Header("Content-Type")String contentType,@Header("register") String registerActive, 
    @Field("grant_type") String grantType,@Field("client_id") String clientId,
    @Field("client_secret") String clientSecret,Callback<RegisterToken> callback);
}

在 activity 我这样做了 :

Gson gson = new GsonBuilder()
            .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
            .create();

    Retrofit client = new Retrofit.Builder()
            .baseUrl(getResources().getString(R.string.base_api_url))
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();


    APIService service = client.create(APIService.class);
    Callback<RegisterToken> registerToken=service.getRegisterToken("application/json", 
        "application/json", "active", grant_type, client_id, client_secret,
        new Callback<RegisterToken>() {
        @Override
        public void onResponse(retrofit2.Response<RegisterToken> response) {
            Log.v("good","okkay");
        }

        @Override
        public void onFailure(Throwable t) {
            Log.v("bad","shithapp");
        }
    });

这是我想做的 postman 截图:

所以我收到了这个错误:

java.lang.IllegalArgumentException: Unable to create call adapter for
retrofit2.Callback<RegisterToken> for method APIService.getRegisterToken

我找不到这里有什么问题,我已经尝试并查看了很多 Whosebug 问题,但找不到解决方案:(

在界面APIService中,将getRegisterToken(...)的return类型改为void。您将通过最后一个回调参数收到 POST 结果通知。

因此也删除 service.getRegisterToken 之前的 Callback<RegisterToken> registerToken =