0
我試圖像這樣改造@POST並不適用於輸入
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
import com.dolphithronelab.siastar.response.AuthResponse;
public interface SIAStarService {
@POST("auth");
@FormUrlEncoded;
Call<AuthResponse>login(@Field("username") String username, @Field("password") String password);
}
但我的Android工作室顯示錯誤說創建簡單的服務:@POST不適用打字,如何面對呢?這是我的AuthResponse類 import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName;
public class AuthResponse {
@SerializedName("login")
@Expose
private Boolean login;
@SerializedName("user")
@Expose
private User user;
@SerializedName("pesan")
@Expose
private String pesan;
@SerializedName("token")
@Expose
private String token;
public Boolean getLogin() {
return login;
}
public void setLogin(Boolean login) {
this.login = login;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getPesan() {
return pesan;
}
public void setPesan(String pesan) {
this.pesan = pesan;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}