{"comment":{"created_at":"2011-10-23T22:30:15Z","body":"Rewriting line 8 this way solved it:\r\n\r\n    produce(text/html) { post { request:HttpRequest[ByteChunk] => reqDocument(log, request) } }\r\n\r\nHowever, the reqDocument() function finds no parameters. ( ````java.util.NoSuchElementException: key not found: 'document````)\r\n\r\n````\r\n  private def reqDocument[T](log:Logger, request:HttpRequest[T]) = {\r\n    val params = request.parameters\r\n    for (kv<-params)\r\n      log.info(kv.toString())\r\n    try {\r\n      val document:String = request.parameters('document)\r\n      val response = HttpResponse[String](content = Some(\"Uploaded document has \" + document.length + \" characters\"))\r\n      Future.sync(response)\r\n    } catch {\r\n      case e:Exception =>\r\n        log.info(e.toString)\r\n        Future.sync(HttpResponse[String](content=Some(e.toString)))\r\n    }\r\n  }\r\n````\r\n\r\n... when invoked by curl this way:\r\n\r\n    curl -sSv --data-urlencode \"sessionid=$SESSION_ID&document=Of course you realize that this means war\" \"http://localhost:8585/upload\"\r\n\r\nSame result when invoked from this web page:\r\n\r\n````\r\n<form method=post action=\"http://localhost:8585/upload\">\r\n    <input type=hidden name=sessionid value=bogus>\r\n    <input type=hidden name=document value=\"Of course you realize that this means war\">\r\n    <input type=submit>\r\n</form>\r\n````","updated_at":"2011-10-23T22:30:15Z","url":"https://api.github.com/repos/jdegoes/blueeyes/issues/comments/2498295","id":2498295,"user":{"avatar_url":"https://secure.gravatar.com/avatar/afb2df7bcc45185335c2f48024aae7f1?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"afb2df7bcc45185335c2f48024aae7f1","url":"https://api.github.com/users/mslinn","id":485818,"login":"mslinn"}},"action":"created","issue":{"number":29,"created_at":"2011-10-22T19:46:57Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Given this CURL POST:\r\n\r\n    curl -sSv --header Content-Type:application/json --data-urlencode 'document=Of course you realize that this means war' http://localhost:8585/json/blah/78e68fde-3995-4a35-bdc7-8746c6a2e47b\r\n\r\nwith this response:\r\n\r\n````\r\n* About to connect() to localhost port 8585 (#0)\r\n*   Trying 127.0.0.1... connected\r\n* Connected to localhost (127.0.0.1) port 8585 (#0)\r\n> POST /json/blah/7672be51-88d3-4b86-b69d-fc72cfbbf64e HTTP/1.1\r\n> User-Agent: curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.21.6 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 librtmp/2.3\r\n> Host: localhost:8585\r\n> Accept: */*\r\n> Content-Type:application/json\r\n> Content-Length: 64\r\n> \r\n} [data not shown]\r\n< HTTP/1.1 500 There was an internal server error.\r\n< Content-Length: 0\r\n< \r\n* Connection #0 to host localhost left intact\r\n* Closing connection #0\r\n````\r\n\r\nI get the following error message:\r\n\r\n````\r\nERR [20111022-12:40:39.053] blueeyes: Error handling request\r\nERR [20111022-12:40:39.053] blueeyes: blueeyes.json.JsonParser$ParseException: Data is too big, use big data handler. If \"aggregate\" combinator is used then probably Json is broken.\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.data.BijectionsChunkJson$$anon$1.unapply(BijectionsChunkJson.scala:23)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.data.BijectionsChunkJson$$anon$1.unapply(BijectionsChunkJson.scala:11)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.data.Bijection$$anon$1.apply(Bijection.scala:20)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anon$10$$anonfun$apply$10.apply(HttpRequestHandlerCombinators.scala:347)\r\nERR [20111022-12:40:39.053] blueeyes:     at scala.Option.map(Option.scala:133)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anon$10.apply(HttpRequestHandlerCombinators.scala:347)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anon$10.apply(HttpRequestHandlerCombinators.scala:331)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anonfun$path$1$$anon$1.apply(HttpRequestHandlerCombinators.scala:36)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anonfun$path$1$$anon$1.apply(HttpRequestHandlerCombinators.scala:28)\r\nERR [20111022-12:40:39.053] blueeyes:     at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:46)\r\nERR [20111022-12:40:39.053] blueeyes:     at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpServer$class.apply(HttpServer.scala:68)\r\nERR [20111022-12:40:39.053] blueeyes:     at net.interdoodle.hbe.AppServer$.apply(AppServer.scala:7)\r\nERR [20111022-12:40:39.053] blueeyes:     at net.interdoodle.hbe.AppServer$.apply(AppServer.scala:7)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.engines.NettyRequestHandler.messageReceived(NettyRequestHandler.scala:43)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.engines.NettyChunkedRequestHandler$$anonfun$messageReceived$1.apply(NettyChunkedRequestHandler.scala:58)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.engines.NettyChunkedRequestHandler$$anonfun$messageReceived$1.apply(NettyChunkedRequestHandler.scala:43)\r\nERR [20111022-12:40:39.053] blueeyes:     at scala.Option.foreach(Option.scala:197)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.engines.NettyChunkedRequestHandler.messageReceived(NettyChunkedRequestHandler.scala:43)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleUpstream(ChunkedWriteHandler.java:148)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)\r\nERR [20111022-12:40:39.053] blueeyes:     (...more...)\r\nERR [20111022-12:40:39.053] blueeyes: Caused by blueeyes.json.JsonParser$ParseException: unknown token d\r\nNear: document=Of%20course%\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.json.JsonParser$Parser.fail(JsonParser.scala:230)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.json.JsonParser$Parser.nextToken(JsonParser.scala:325)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.json.JsonParser$$anonfun$4.apply(JsonParser.scala:188)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.json.JsonParser$$anonfun$4.apply(JsonParser.scala:142)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.json.JsonParser$.parse(JsonParser.scala:75)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.json.JsonParser$.parse(JsonParser.scala:51)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.data.BijectionsChunkJson$$anon$1.unapply(BijectionsChunkJson.scala:21)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.data.BijectionsChunkJson$$anon$1.unapply(BijectionsChunkJson.scala:11)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.data.Bijection$$anon$1.apply(Bijection.scala:20)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anon$10$$anonfun$apply$10.apply(HttpRequestHandlerCombinators.scala:347)\r\nERR [20111022-12:40:39.053] blueeyes:     at scala.Option.map(Option.scala:133)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anon$10.apply(HttpRequestHandlerCombinators.scala:347)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anon$10.apply(HttpRequestHandlerCombinators.scala:331)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anonfun$path$1$$anon$1.apply(HttpRequestHandlerCombinators.scala:36)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpRequestHandlerCombinators$$anonfun$path$1$$anon$1.apply(HttpRequestHandlerCombinators.scala:28)\r\nERR [20111022-12:40:39.053] blueeyes:     at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:46)\r\nERR [20111022-12:40:39.053] blueeyes:     at scala.PartialFunction$$anon$1.apply(PartialFunction.scala:45)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.HttpServer$class.apply(HttpServer.scala:68)\r\nERR [20111022-12:40:39.053] blueeyes:     at net.interdoodle.hbe.AppServer$.apply(AppServer.scala:7)\r\nERR [20111022-12:40:39.053] blueeyes:     at net.interdoodle.hbe.AppServer$.apply(AppServer.scala:7)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.engines.NettyRequestHandler.messageReceived(NettyRequestHandler.scala:43)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:545)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:754)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.engines.NettyChunkedRequestHandler$$anonfun$messageReceived$1.apply(NettyChunkedRequestHandler.scala:58)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.engines.NettyChunkedRequestHandler$$anonfun$messageReceived$1.apply(NettyChunkedRequestHandler.scala:43)\r\nERR [20111022-12:40:39.053] blueeyes:     at scala.Option.foreach(Option.scala:197)\r\nERR [20111022-12:40:39.053] blueeyes:     at blueeyes.core.service.engines.NettyChunkedRequestHandler.messageReceived(NettyChunkedRequestHandler.scala:43)\r\nERR [20111022-12:40:39.053] blueeyes:     at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:80)\r\nERR [20111022-12:40:39.053] blueeyes:     (...more...)\r\n````\r\n\r\nfrom the following JsonService trait:\r\n\r\n````\r\npackage net.interdoodle.hbe\r\n\r\nimport blueeyes._\r\nimport blueeyes.concurrent.Future\r\nimport blueeyes.core.data.{BijectionsChunkJson, BijectionsChunkString, ByteChunk}\r\nimport blueeyes.core.http.{HttpRequest, HttpResponse, HttpStatus}\r\nimport blueeyes.core.http.{HttpCookie, HttpDateTime}\r\nimport blueeyes.core.http.combinators.HttpRequestCombinators\r\nimport blueeyes.core.service.{HttpService, HttpServiceContext}\r\nimport blueeyes.json.JsonAST._\r\nimport net.interdoodle.hbe.domain.Hanuman\r\nimport scala.collection.mutable.HashMap\r\nimport java.util.UUID\r\n\r\n\r\n  trait HelloJsonServices extends BlueEyesServiceBuilder\r\n    with HttpRequestCombinators\r\n    with BijectionsChunkString\r\n    with BijectionsChunkJson {\r\n\r\n  val sessions = new HashMap[String, Some[Hanuman]]()\r\n\r\n  val helloJson: HttpService[ByteChunk] = service(\"helloJson\", \"0.1\") {\r\n    requestLogging {\r\n      logging {\r\n        log =>\r\n          context: HttpServiceContext =>\r\n            request {\r\n              path(\"/json/\") {\r\n                jvalue {\r\n                  get {\r\n                    requestParam:HttpRequest[JValue] =>\r\n                      val json = JString(\"Hello World!\")\r\n                      val response = HttpResponse[JValue](content = Some(json))\r\n                      log.info(response.toString())\r\n                      Future.sync(response)\r\n                  } ~\r\n                  path('operation) {\r\n                    get { request =>\r\n                      val operation = request.parameters('operation)\r\n                      if (operation==\"newSession\") {\r\n                        val sessionID = UUID.randomUUID().toString\r\n                        sessions += sessionID -> Some(null)\r\n                        Future.sync(HttpResponse(\r\n                          /*headers = HttpHeaders.Empty + sessionCookie(sessionID),*/\r\n                          content = Some(sessionID)))\r\n                      } else {\r\n                        val msg = \"The only operation that can be without a sessionID is newSession. You specified '\" + operation + \"'\"\r\n                        Future.sync(HttpResponse(status=HttpStatus(400, msg),\r\n                                                 content = Some(msg)))\r\n                      }\r\n                    }\r\n                  } ~\r\n                  path('operation/'id) {\r\n                    post { request =>\r\n                      val operation = request.parameters('operation)\r\n                      val sessionID = request.parameters('id)\r\n                      val session = sessions.getOrElse(sessionID, None)\r\n                      Future.sync(HttpResponse(\r\n                        /*headers = HttpHeaders.Empty + sessionCookie(sessionID),*/\r\n                        content = if (session==null)\r\n                          Some(\"Session with ID \" + sessionID + \" does not exist\")\r\n                        else\r\n                          Some(\"session ID=\" + sessionID + \"; operation: '\" + operation + \"'\"))\r\n                      )\r\n                    }\r\n                  } ~\r\n                  path('operation/'id/'param) {\r\n                    post { request =>\r\n                      val operation = request.parameters('operation)\r\n                      val sessionID = request.parameters('id)\r\n                      val param = request.parameters('param)\r\n                      val session = sessions.getOrElse(sessionID, None)\r\n                      Future.sync(HttpResponse(\r\n                        /*headers = HttpHeaders.Empty + sessionCookie(sessionID),*/\r\n                        content = if (session==null)\r\n                          Some(\"Session with ID \" + sessionID + \" does not exist\")\r\n                        else\r\n                          Some(\"session ID=\" + sessionID + \"; operation: '\" + operation + \"'\"))\r\n                      )\r\n                    }\r\n                  }\r\n                }\r\n              }\r\n            }\r\n      }\r\n    }\r\n  }\r\n}\r\n```` \r\n\r\nThe error does not manifest with an HTTP GET, when the service is modified for get instead of post.","comments":6,"title":"HTTP POST fails","updated_at":"2011-10-23T22:30:15Z","url":"https://api.github.com/repos/jdegoes/blueeyes/issues/29","id":2024159,"assignee":null,"milestone":null,"closed_at":"2011-10-23T17:20:43Z","user":{"avatar_url":"https://secure.gravatar.com/avatar/afb2df7bcc45185335c2f48024aae7f1?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"afb2df7bcc45185335c2f48024aae7f1","url":"https://api.github.com/users/mslinn","id":485818,"login":"mslinn"},"html_url":"https://github.com/jdegoes/blueeyes/issues/29","labels":[],"state":"closed"},"legacy":{"issue_id":2024159,"comment_id":2498295}}