This API does not support parsing form-encoded input

霸气de小男生 提交于 2019-11-29 11:52:16

问题


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.

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"
 }
}

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!


回答1:


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

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.

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


来源:https://stackoverflow.com/questions/19261862/this-api-does-not-support-parsing-form-encoded-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!