此API不支持解析表单编码输入

Sha*_*aun 19 java google-app-engine google-cloud-endpoints

我试图将数据提交到端点,但它说数据大小太大,所以我将方法更改为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中.

此外,与许多事情一样,这在我的本地计算机上运行良好,它只在实时应用程序引擎实例上提供此错误.

谢谢!

Gre*_*reg 27

不确定您的问题是否相关,但我收到"此API不支持解析表单编码输入".我尝试使用curl发送这样的POST消息时出错:

curl -X POST -d '{"name": "Foo"}' http://foo.appspot.com/_ah/api/foo/1/endpoint
Run Code Online (Sandbox Code Playgroud)

问题是我没有设置内容类型.如果在命令行中未指定,则使用Content-Type卷曲POST:application/x-www-form-urlencoded.Google云端点不接受此内容类型.

当我更改curl调用以包含内容类型时,它工作:

curl -X POST -d '{"name": "Foo"}' --header "Content-Type: application/json" http://foo.appspot.com/_ah/api/foo/1/endpoint
Run Code Online (Sandbox Code Playgroud)