当我尝试在我的 Android 应用程序中使用 GAE 来检索特定实体时出现以下错误(只有其中一些实体,其他实体正常工作)。错误是:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal Error",
"reason" : "internalError"
} ],
"message" : "Internal Error"
}
com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal Error",
"reason" : "internalError"
} ],
"message" : "Internal Error"
}
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal Error",
"reason" : "internalError"
} ],
"message" : "Internal Error"
}
500 Internal Server Error
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal Error",
"reason" : "internalError"
} ],
"message" : "Internal Error"
}
{"code":500,"errors":[{"domain":"global","message":"Internal Error","reason":"internalError"}],"message":"Internal Error"}
这似乎没有帮助,我尝试通过此链接中的最佳答案添加日志记录,但这也不起作用(没有将日志发布到 Cloud Console,或者至少没有我试图实现的任何日志)。我的实体类主题定义为:
public class ZooperTheme {
@Id
private String themeID;
public String creator;
public String date;
public String address;
public int version;
public String name;
public int size;
public int downloads;
public int favorites;
public int hides;
public int popularity;
public int errors;
public String items;
它对每个都有适当的 getter/setter。themeID 是从 1、2、3 等开始的 Long 并转换为字符串。当我使用以下代码时,一切正常(它下载所有主题信息并转换为 SQL 数据库:
themeendpoint.Builder endpointBuilder = new themeendpoint.Builder(
AndroidHttp.newCompatibleTransport(),
new JacksonFactory(),
new HttpRequestInitializer() {
public void initialize(HttpRequest httpRequest) { }
});
endpointBuilder.setApplicationName(mCtx.getString(R.string.app_name));
themeendpoint endpoint = CloudEndpointUtils.updateBuilder(
endpointBuilder).build();
DbAdapter dbAdapter = new DbAdapter(mCtx);
dbAdapter.openWrite();
dbAdapter.wipeThemeData();
try {
CollectionResponseTheme response = endpoint.listTheme().execute();
List<Theme> listResponse = response.getItems();
for (Theme zt : listResponse) {
String themeID = zt.getThemeID();
String creator = zt.getCreator();
String date = zt.getDate();
String address = zt.getAddress();
int version = zt.getVersion();
String name = zt.getName();
int size = zt.getSize();
int popularity = zt.getPopularity();
String items = zt.getItems();
if (!(items != null)) {
items = "";
}
dbAdapter.insertTheme(themeID, creator, date, address, "" + version, name, "" + size, "" + popularity, items);
}
但是,当我尝试使用相同的代码来创建上面的端点时,请尝试以下操作:
Theme theme2 = endpoint.getTheme("2").execute();
Theme theme1 = endpoint.getTheme("1").execute();
主题 2 完美运行,但主题 1 得到 500 代码错误!两者之间的唯一区别是,对于主题“1”,Items 列有信息(只是一个字符串“test”),而主题“2”对于该列是空白的。除此之外,没有任何区别。我已经用其他主题 ID 对此进行了测试,并且始终如一地,如果 Items 列是空白的,则代码有效,如果其中有任何内容,则会出现代码 500。这里可能发生什么?