Java 谷歌云端点SPI受限
我使用Google云端点定义了一个简单的API:Java 谷歌云端点SPI受限,java,google-app-engine,google-cloud-endpoints,Java,Google App Engine,Google Cloud Endpoints,我使用Google云端点定义了一个简单的API: @Api(name = "realestate", version = "v1") public class RealEstatePropertyV1 { @ApiMethod(name = "properties", httpMethod = "GET") public List<RealEstateProperty> list() { return ofy().load().type(RealEs
@Api(name = "realestate", version = "v1")
public class RealEstatePropertyV1 {
@ApiMethod(name = "properties", httpMethod = "GET")
public List<RealEstateProperty> list() {
return ofy().load().type(RealEstateProperty.class).list();
}
}
我在eclipse中启动API并执行curlhttp://localhost:8888/_ah/spi/realestate/v1/properties
。答案是
<html><head><title>Error 405 HTTP method GET is not supported by this URL</title></head>
<body><h2>Error 405 HTTP method GET is not supported by this URL</h2></body>
</html>
你知道
SPI restricted
是什么意思吗?我想提一下,我没有在GoogleAPI控制台中注册任何东西。我的目标是首先在本地测试API。要测试您的应用程序,请尝试
curl -X POST -d "{}" \
> -H "Content-Type: application/json" \
> http://localhost:8888/_ah/spi/realestate/v1/properties
更好的是,使用API资源管理器测试您的应用程序
http://localhost:8888/_ah/api/explorer
至于日志中的
SPI restricted
,这只是指示该方法是否已设置了auth。在您的例子中,对于这个方法,它是true
使用curl
命令,我得到以下信息:{“error\u message”:“missing/{Service}.{method}}
。我没有在App Engine上部署API,可能这就是原因。这与localhost:8888
无关。什么是{Service}
?因为我没有为@ApiMethod
指定路径
属性,所以正确的URL是http://localhost:8888/_ah/api/realestate/v1/realestateproperty
。我从API资源管理器那里得到的。起初它不起作用,因为我使用的是objectify
,它似乎不适用于端点。请随意发布您在使用端点时遇到的问题。我们很乐意提供帮助。在我的一个实体中,我有一个字段@Parent Ref
,似乎没有处理Ref
,因为如果我有这个字段,我就无法生成客户端库,而且什么都不起作用。我使用Objectify 4
curl -X POST -d "{}" \
> -H "Content-Type: application/json" \
> http://localhost:8888/_ah/spi/realestate/v1/properties
http://localhost:8888/_ah/api/explorer