此API不支持解析表单编码输入 [英] This API does not support parsing form-encoded input

查看:142
本文介绍了此API不支持解析表单编码输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将数据提交给端点,但它说数据大小太大,所以我将该方法更改为POST并收到错误:

I tried to submit data to an endpoint but it said the data size was too large, so I changed the method to POST and received the error:

This API does not support parsing form-encoded input.

接下来,我将类型更改为application / json,仍然使用post,现在我得到了: p>

Next I changed the type to application/json, still with post and now I am getting:

{
"error": {
  "errors": [
  {
    "domain": "global",
"reason": "parseError",
  "message": "Parse Error"
 }
 ],
  "code": 400,
 "message": "Parse Error"
 }
}

发布大量数据的最佳方式是什么,即将2730字节发布到端点并让它正确处理?在我的案例中,所涉及的字段的类型是Text,因为我超过了500个字符限制,以便应用引擎保存在字符串中。

What is the best way to post a large amount of data, i.e. 2730 bytes to an endpoint and have it handle it properly? In my case the field in question is of type Text as I am over the 500 character limit for app engine to hold in a String.

另外,这在我的本地机器上效果很好,它只会在实时应用程序引擎实例中出现此错误。

Also, as with many things, this works great on my local machine, it only gives this error on the live app engine instance.

谢谢!

Thanks!

推荐答案

不确定您的问题是否相关,但我收到此API不支持解析表单编码输入。错误,当我试图用curl发送POST消息,如下所示:

Not sure if your problem is related, but I received the "This API does not support parsing form-encoded input." error when I was attempting to use curl to send a POST message like this:

curl -X POST -d '{"name": "Foo"}' http://foo.appspot.com/_ah/api/foo/1/endpoint

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

The problem was that I was not setting the content type. curl POSTs with Content-Type: application/x-www-form-urlencoded if it's not specified on the command line. Google cloud endpoints don't accept this content type.

当我将curl调用更改为包含内容类型时,它工作正常:

When I changed the curl invocation to include the content type, it worked:

curl -X POST -d '{"name": "Foo"}' --header "Content-Type: application/json" http://foo.appspot.com/_ah/api/foo/1/endpoint

这篇关于此API不支持解析表单编码输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆