21

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!

Shaun
  • 1,581
  • 2
  • 16
  • 35
  • A string can be almost the full 1MB allowed in a datastore entity (need to leave space for the key and nothing else). If you don't persist the input, you can accept 32MB of string in a request. – bossylobster Oct 17 '13 at 04:07
  • @bossylobster What I notice is that if you have an entity type in the endpoint it will take a JSON object over a post, but if you only have something like a String or a Long, etc. a Named property then you have to append it to the URL. I think it would be better to standardize on JSON or give us more control when we define the API endpoints to force it to use/take JSON. – Shaun Oct 30 '13 at 21:07
  • A named property by definition ends up as a path parameter. However, parameter name collisions are allowed, so you can also define it in the body. – bossylobster Oct 31 '13 at 18:26

1 Answers1

31

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
Greg
  • 33,450
  • 15
  • 93
  • 100