4
votes

I suspect this is caused by the following bug in Endpoints (if valid) but I'm also sure there's a workaround somewhere.

https://code.google.com/p/googleappengine/issues/detail?id=9050&can=4&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log

Steps to reproduce:

  1. Change a method name, API name of a method, or parameter list in an Endpoints class.
  2. Run the endpoints.sh script to generate the API files.
  3. Inspect the API files locally and witness the changes being there. So far so good.
  4. Deploy to the default version of the app on the server.
  5. Check the logs for the call to /_ah/spi/BackendService.getApiConfigs. There are no errors!
  6. Go to API Explorer and clear the browser cache. Inspect the API. The change is not there.
  7. Request the API file directly in the browser, eg. https://[app-id].appspot.com/_ah/api/discovery/v1/apis/[api-name]/v1/rpc The change is not there.

Frustrated with the above, I decided to start completely from scratch on a new app ID. I still see no API in the API Explorer and get a 404 on the URL in step 7 above!

Here's my endpoint class:

@Api(name = "ditto", version = "v1")
public class CategoryEndpoint extends BaseEndpoint {

    @SuppressWarnings("unused")
    private static final Logger log = Logger.getLogger(CategoryEndpoint.class.getName());

    @ApiMethod(name = "category.list")
    public WireCategory list() {
        Category root = categoryDao.getRoot();
        WireCategory wireRootCategory = new WireCategory(root);

        return wireRootCategory;
    }

}

And here's the generated .api file:

{
  "extends" : "thirdParty.api",
  "abstract" : false,
  "root" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/api",
  "name" : "ditto",
  "version" : "v1",
  "defaultVersion" : false,
  "adapter" : {
    "bns" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
    "deadline" : 10.0,
    "type" : "lily"
  },
  "auth" : {
    "allowCookieAuth" : false
  },
  "frontendLimits" : {
    "unregisteredUserQps" : -1,
    "unregisteredQps" : -1,
    "unregisteredDaily" : -1,
    "rules" : [ ]
  },
  "cacheControl" : {
    "type" : "no-cache",
    "maxAge" : 0
  },
  "methods" : {
    "ditto.category.list" : {
      "path" : "list",
      "httpMethod" : "GET",
      "scopes" : [ ],
      "audiences" : [ ],
      "clientIds" : [ ],
      "rosyMethod" : "ditto.api.CategoryEndpoint.list",
      "request" : {
        "body" : "empty"
      },
      "response" : {
        "body" : "autoTemplate(backendResponse)"
      }
    }
  },
  "descriptor" : {
    "schemas" : {
      "WireCategory" : {
        "id" : "WireCategory",
        "type" : "object",
        "properties" : {
          "webSafePath" : {
            "type" : "string"
          },
          "prettyPath" : {
            "type" : "string"
          },
          "children" : {
            "type" : "array",
            "items" : {
              "$ref" : "WireCategory"
            }
          },
          "path" : {
            "type" : "array",
            "items" : {
              "type" : "string"
            }
          },
          "name" : {
            "type" : "string"
          },
          "id" : {
            "type" : "string",
            "format" : "int64"
          }
        }
      }
    },
    "methods" : {
      "ditto.api.CategoryEndpoint.list" : {
        "response" : {
          "$ref" : "WireCategory"
        }
      }
    }
  }
}

This URL gives me a 404 where I expect to see my API JSON:

https://eliot-dev-uk-ditto-do.appspot.com/_ah/api/discovery/v1/apis/ditto/v1

This is killing me!

EDIT:

Here's a diff I just spotted between the .api file generated by App Engine 1.7.5 and 1.7.6. Not sure why the URLs have changed.

ditto-v1.api from 1.7.6:

    {
      "extends" : "thirdParty.api",
      "abstract" : false,
      "root" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/api",
      "name" : "ditto",
      "version" : "v1",
      "defaultVersion" : false,
      "adapter" : {
        "bns" : "https://1.eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
        "deadline" : 10.0,
        "type" : "lily"
      }
      ...

    ditto-v1.api from 1.7.5:

     {
      "extends" : "thirdParty.api",
      "abstract" : false,
      "root" : "https://eliot-dev-uk-ditto-do.appspot.com/_ah/api",
      "name" : "ditto",
      "version" : "v1",
      "defaultVersion" : false,
      "adapter" : {
        "bns" : "http://eliot-dev-uk-ditto-do.appspot.com/_ah/spi",
        "deadline" : 10.0,
        "type" : "lily"
      }
      ...
1
We think this is an issue with the 1.7.6 SDK and we are trying to get to the bottom of this. Are you having similar issues with the 1.7.5 SDK?bossylobster
Switching back to 1.7.5 does indeed fix the problem. I can see my API in the API explorer. Have also noticed a diff in the .api file across versions of App Engine, which I'll add to the question above.Eliot
It seems the best work-around will be to use the 1.7.5 SDK until the 1.7.7 SDK comes out or to manually change the root and adapter.bns values in your .api file. Sorry for this inconvenience.bossylobster

1 Answers

2
votes

As you already pointed out, it was due to an weird issue in SDK 1.7.6, which adds that 1. at the beginning of the endpoint root url in the .api files...

I've tried the new SDK 1.7.7 and it seems to be solved...