我试图将数据提交到端点,但它说数据大小太大,所以我将方法更改为POST并收到错误:
This API does not support parsing form-encoded input.
Run Code Online (Sandbox Code Playgroud)
接下来我将类型更改为application/json,仍然使用post,现在我得到:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}
Run Code Online (Sandbox Code Playgroud)
将大量数据(即2730字节)发布到端点并使其正确处理的最佳方法是什么?在我的情况下,有问题的字段是Text类型,因为我超过500个字符限制,app引擎要保存在String中.
此外,与许多事情一样,这在我的本地计算机上运行良好,它只在实时应用程序引擎实例上提供此错误.
谢谢!
由于未知原因,当我尝试构建我的Google App Engine端点时,我在Android Studio生成的所有API java文件中都出现了这些错误:
错误:(400,5)错误:方法没有覆盖或实现超类型的方法错误:(402,29)错误:找不到符号方法setBatchPath(String)
我做了一些初步的故障排除,发现java文件中有一个Builder类,它扩展了AbstractGoogleJsonClient.Builder.我查看了Builder类的源代码,但是找不到该方法.
为什么突然间我得到这些错误?救命!
是否有一种灵活的方式来启用CORS与云端点?
(在响应中添加"Access-Control-Allow-Origin:*"或类似内容)
谢谢,布兰登
我目前正在使用EndpointsModel为AppEngine上的所有模型创建RESTful API.由于它是RESTful,这些api有很多重复代码,我想避免
例如:
class Reducer(EndpointsModel):
name = ndb.StringProperty(indexed=False)
@endpoints.api(
name="bigdata",
version="v1",
description="""The BigData API""",
allowed_client_ids=ALLOWED_CLIENT_IDS,
)
class BigDataApi(remote.Service):
@Reducer.method(
path="reducer",
http_method="POST",
name="reducer.insert",
user_required=True,
)
def ReducerInsert(self, obj):
pass
## and GET, POST, PUT, DELETE
## REPEATED for each model
Run Code Online (Sandbox Code Playgroud)
我想让它们变得通用.所以我尝试动态添加方法到类.到目前为止我尝试了什么:
from functools import partial, wraps
def GenericInsert(self, obj, cls):
obj.owner = endpoints.get_current_user()
obj.put()
return obj
# Ignore GenericDelete, GenericGet, GenericUpdate ...
import types
from functools import partial
def register_rest_api(api_server, endpoint_cls):
name = endpoint_cls.__name__
# create list method
query_method = types.MethodType( …Run Code Online (Sandbox Code Playgroud) python google-app-engine functools google-cloud-endpoints endpoints-proto-datastore
我正在尝试构建一个Endpoints应用程序,但我是Google App Engine的新手.
根据我的理解,SDK中包含某种API Explorer,可以让我测试/验证我的API - 文档说:"通过导航到Google API Explorer中测试API后端http://localhost:8080/_ah/api/explorer".但是我找不到任何关于API Explorer实际上是,做什么或看起来像什么的文档.
在任何情况下,当我尝试点击该网址时,我会立即重定向到https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/,告诉我什么都没有用,似乎它必定是某种错误.
devappserver日志说:
INFO 2013-07-17 17:27:54,574 server.py:593] default: "GET /_ah/api/explorer HTTP/1.1" 302 -
INFO 2013-07-17 17:27:56,099 server.py:593] default: "GET /_ah/api/static/proxy.html?jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.7JUwNUXMAS8.O%2Fm%3D__features__%2Fam%3DEQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAItRSTO0dpKS_pssf5r3z87E6FlFvDGdOg HTTP/1.1" 200 1933
INFO 2013-07-17 17:27:56,193 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO 2013-07-17 17:27:56,492 server.py:593] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 200 576
INFO 2013-07-17 17:27:56,507 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO 2013-07-17 17:27:56,583 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO 2013-07-17 17:27:56,811 server.py:593] …Run Code Online (Sandbox Code Playgroud) 我正在使用appengine云端点和客观化.我之前已经部署了这些端点,现在我正在更新它们,它不能与Objectify一起使用.我已经搬到了新机器并运行最新的appengine 1.8.6.尝试将objectify放在classpath中并且不起作用.我知道这可以工作,我错过了什么?
运行endpoints.sh时:
Error: Parameterized type
com.googlecode.objectify.Key<MyClass> not supported.
Run Code Online (Sandbox Code Playgroud)
更新:我回到我的旧计算机并在同一端点上运行endpoints.sh并且工作正常.旧机器有1.8.3.我正在使用客观化3.1.
更新2:将我的旧机器更新为1.8.6并获得与其他机器相同的错误.留下2种可能性:1)端点不再支持客观化3.1 或 2)端点在最新版本中存在错误
最有可能#1 ...我一直想要更新到4.0 ...
我可以使用Javascript客户端从Google Cloud Endpoints获取博客帖子列表:
gapi.client.blog.posts.list().execute(function (resp) {
console.log(resp);
});
Run Code Online (Sandbox Code Playgroud)
但我需要在Google Cloud Endpoints请求中设置包含用户令牌的自定义标头值(这可能是来自Facebook的访问令牌).如何使用Google的Javascript客户端执行此操作?我可以通过不使用谷歌的Javascript客户端解决这个问题,但我宁愿使用它.
https://developers.google.com/appengine/docs/java/endpoints/consume_js https://developers.google.com/api-client-library/javascript/reference/referencedocs
编辑
看来我可以像这样传递自定义标头值:
gapi.auth.setToken({
access_token: 'this is my custom value'
});
Run Code Online (Sandbox Code Playgroud)
虽然看起来不是很好的做法.有一个更好的方法吗?
最近查了一下,Google 发布了一个API Gateway产品,但是我不明白已经创建的Cloud Endpoints之间有什么区别,它们似乎非常相似。
是API Gateway新版本Cloud Endpoints吗?。或者有什么不同?
提前致谢!
google-cloud-endpoints google-cloud-platform google-cloud-api-gateway
我一直在API资源管理器(localhost)中查看我的Google App Engine端点API而没有任何问题,现在我得到了这个:

它完整地说:
您正在探索通过HTTP而不是HTTPS描述或提供的API.这是不安全的,可能会被您的浏览器阻止.要解决此问题,请为您的API设置TLS代理.或者,您可以告诉您的浏览器在此站点通过HTTP允许活动内容(在Chrome上,单击URL栏中的屏蔽),但这不会提高安全性或忽略此消息.
这是我的端点中的API方法之一:
@ApiMethod(
name = "insert",
path = "movie",
httpMethod = ApiMethod.HttpMethod.POST)
public Movie insert(Movie movie) throws UnauthorizedException {
...
}
Run Code Online (Sandbox Code Playgroud)
由于我不知道是什么导致这一切突然,我不知道还有什么要显示.我尝试更新我的浏览器(Firefox,Opera,Chrome)没有运气.
firefox opera google-app-engine android google-cloud-endpoints
我在App Engine上部署了Endpoints API.我使用Google API资源管理器向不需要登录的API方法发出请求没有问题.我使用的URL是:
https://developers.google.com/apis-explorer/?base=https://[MY_APP_ID].appspot.com/_ah/api
我遇到的问题是调用需要用户登录的API方法,例如:
@ApiMethod(name = "config.get",
clientIds = {"[MY_CLIENT_ID].apps.googleusercontent.com", "com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID"},
audiences = {"[MY_APP_ID].appspot.com"},
scopes = {"https://www.googleapis.com/auth/userinfo.email"})
public Config getConfig(User user) throws OAuthRequestException {
log.fine("user: " + user);
if (user == null) {
throw new OAuthRequestException("You must be logged in in order to get config.");
}
if (!userService.isUserAdmin()) {
throw new OAuthRequestException("You must be an App Engine admin in order to get config.");
}
...
Run Code Online (Sandbox Code Playgroud)
在API资源管理器上有一个右上角的开关,当单击它时,允许我指定范围和授权.我只是检查了userinfo.email范围.没什么区别.我从电话中得到的回应是:
503 Service Unavailable
- Show headers -
{
"error": {
"errors": [ …Run Code Online (Sandbox Code Playgroud)