Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 谷歌云端点SPI受限_Java_Google App Engine_Google Cloud Endpoints - Fatal编程技术网

Java 谷歌云端点SPI受限

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

我使用Google云端点定义了一个简单的API:

@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