Hey, thanks for all the help so far, stuck on a new thing!
I'm trying to post JSON to one of our APIs running Espresso.
If I make this request:
Espresso generates a request like this as I'd expect:
(Inside Item controller)
#<EspressoRequest:0x007fc172c534e8 @env={"SERVER_SOFTWARE"=>"thin 1.5.0 codename Knife", "SERVER_NAME"=>"localhost", "rack.input"=>#<StringIO:0x007fc172c54208>, "rack.version"=>[1, 0], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "REQUEST_METHOD"=>"POST", "REQUEST_PATH"=>"/items", "PATH_INFO"=>"", "REQUEST_URI"=>"/items", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_USER_AGENT"=>"curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5", "HTTP_HOST"=>"localhost:3001", "HTTP_ACCEPT"=>"*/*", "CONTENT_LENGTH"=>"90", "CONTENT_TYPE"=>"application/x-www-form-urlencoded", "GATEWAY_INTERFACE"=>"CGI/1.2", "SERVER_PORT"=>"3001", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "rack.url_scheme"=>"http", "SCRIPT_NAME"=>"/items", "REMOTE_ADDR"=>"127.0.0.1", "async.callback"=>#<Method: Thin::Connection#post_process>, "async.close"=>#<EventMachine::DefaultDeferrable:0x007fc172c538a8>, "espresso.path_info"=>nil, "espresso.format"=>nil, "rack.request.query_string"=>"", "rack.request.query_hash"=>{}, "rack.request.form_input"=>#<StringIO:0x007fc172c54208>, "rack.request.form_hash"=>{"json"=>"{\"item\":{\"text\":\"I LIKE CAKE\", \"tags\":[2840]}, \"auth_token\" : \"koz3EX1hAEi3JEwuV9L9\"}"}, "rack.request.form_vars"=>"json={\"item\":{\"text\":\"I LIKE CAKE\", \"tags\":[2840]}, \"auth_token\" : \"koz3EX1hAEi3JEwuV9L9\"}"}, @params={"json"=>"{\"item\":{\"text\":\"I LIKE CAKE\", \"tags\":[2840]}, \"auth_token\" : \"koz3EX1hAEi3JEwuV9L9\"}"}>
But if I make the same request, but set Content-type: application/json, it does not get the params through:
curl -H "Content-type: application/json" -X POST -d ' {"item":{"text":"I LIKE CAKE", "tags":[2840]}, "auth_token" : "koz3EX1hAEi3JEwuV9L9"}'
http://localhost:3001/items#<EspressoRequest:0x007fc172c05cc0 @env={"SERVER_SOFTWARE"=>"thin 1.5.0 codename Knife", "SERVER_NAME"=>"localhost", "rack.input"=>#<StringIO:0x007fc172c06a30>, "rack.version"=>[1, 0], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "REQUEST_METHOD"=>"POST", "REQUEST_PATH"=>"/items", "PATH_INFO"=>"", "REQUEST_URI"=>"/items", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_USER_AGENT"=>"curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5", "HTTP_HOST"=>"localhost:3001", "HTTP_ACCEPT"=>"application/json", "CONTENT_LENGTH"=>"86", "CONTENT_TYPE"=>"application/json", "GATEWAY_INTERFACE"=>"CGI/1.2", "SERVER_PORT"=>"3001", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "rack.url_scheme"=>"http", "SCRIPT_NAME"=>"/items", "REMOTE_ADDR"=>"127.0.0.1", "async.callback"=>#<Method: Thin::Connection#post_process>, "async.close"=>#<EventMachine::DefaultDeferrable:0x007fc172c06288>, "espresso.path_info"=>nil, "espresso.format"=>nil, "rack.request.query_string"=>"", "rack.request.query_hash"=>{}}, @params={}>
How should I set this up?
Joran