easycheese
easycheese

Reputation: 5899

Code 500 Google App Engine Android irrationally shows up, prevents Cloud Datastore retrieval

I am getting the following error when I try to use GAE in my Android app to retrieve particular entities (only some of them, others work perfectly). The error is:

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"}

That doesn't appear helpful, I tried adding logging via the top answer in this link but that didn't work either (no logs were posted to the Cloud Console, or at least any of the logs I was trying to make happen). My Entity class Theme is defined by:

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;

It has the appropriate getters/setters for each. The themeID is a Long starting at 1, 2, 3, etc. and converted to a string. When I use the following code, everything works perfectly (it downloads all the theme information and converts to a SQL db:

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

However, when I try to use the same code to create the endpoint above but try the following:

    Theme theme2 = endpoint.getTheme("2").execute();
    Theme theme1 = endpoint.getTheme("1").execute();

theme2 works perfectly but theme1 gets the 500 code error! The only difference between the two is that for theme "1" the Items column has information (just a string "test") and theme "2" is blank for that column. Other than that, there are no differences. I have tested this with other themeIDs and consistently, if the Items column is blank, the code works, if it has anything in it, the code 500 appears. What could possibly be happening here?

Upvotes: 0

Views: 185

Answers (1)

easycheese
easycheese

Reputation: 5899

So I eventually got it to work. I never solved the problem but it was resolved by:

  1. Adding the package/SHA1 to the credentials page under Public API (I doubt this did anything since it wasn't an access problem"

  2. Threw out everything and re-uploaded the database under a new entity. After that, the problem didn't show up again (yet).

Upvotes: 0

Related Questions