gpt4 book ai didi

android - java.lang.IllegalStateException : Expected a string but was BEGIN_OBJECT at line 1 column 2 path $ 错误

转载 作者:太空狗 更新时间:2023-10-29 13:18:06 32 4
gpt4 key购买 nike

我创建了 Retrofit 界面

public interface UserService {
@GET(Constants.Api.URL_LOGIN)
Call<String> loginUser(@Query("email") String email, @Query("password") String pass, @Query("secret") String secret, @Query("device_id") String deviceid, @Query("pub_key") String pubkey, @Query("device_name") String devicename);

在 Activity 中调用

final Call<String> responce = service.loginUser(loginedt.getText().toString(), md5(passwordedt.getText().toString()), secret, device_id, pub_key, device_name);

responce.enqueue(new Callback<String>() {
@Override
public void onResponse(Response<String> response) {
if (response.code() == Constants.Status.ERROR_404) {
Toast.makeText(LoginActivity.this, getResources().getString(R.string.wrong_log_pass), Toast.LENGTH_LONG).show();
} else if (response.code() != Constants.Status.ERROR_404 && response.code() != Constants.Status.SUCCES) {
Toast.makeText(LoginActivity.this, getResources().getString(R.string.wrong_request), Toast.LENGTH_LONG).show();
} else {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
}
}

@Override
public void onFailure(Throwable t) {
t.printStackTrace();

}
});

我遇到了错误

onFailure java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 2 path $

最佳答案

如果您不创建自己的模型,请使用 Call<JsonObject> .

这是 application/json 内容类型请求的默认解析器。

关于android - java.lang.IllegalStateException : Expected a string but was BEGIN_OBJECT at line 1 column 2 path $ 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32422737/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com