Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6702961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:06:53+00:00 2026-05-26T07:06:53+00:00

I am trying to process JSON data posted to a Rails (3.1.0) controller by

  • 0

I am trying to process JSON data posted to a Rails (3.1.0) controller by accessing the data through the params hash. Unfortunately, Rails does not seem to process the data automatically (as the documentation and other questions on StackOverflow suggest).

The controller looks like:

class Api::EventsController < ApplicationController
  skip_before_filter :verify_authenticity_token

  def create
    unless params['event']['timestamp'].nil?
      ...
    end
    ...

    render :json => { :status => :success }
  end
end

The HTTP request looks like this (captured using tcpdump):

POST /api/locations/1/events HTTP/1.1
Date: Mon, 10 Oct 2011 21:57:22 GMT+00:00
Content-Type: application/json; charset=UTF-8
Accept: application/json
Host: 10.0.2.2:3000
User-Agent: Restlet-Framework/2.1rc1
Authorization: Basic ...
Transfer-Encoding: chunked
Connection: Keep-Alive

4e
{"event":{"data_source":"ANDROID","timestamp":1318283841768,"type":"LEAVING"}}
0

In the above example, params['event'] is always nil. Using ActiveSupport::JSON.decode(request.body) to parse the JSON data works, but I would like to map the request body to parameters automatically.

Edit: request.params just contains routing information and request.request_parameters is completely empty.

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:06:54+00:00Added an answer on May 26, 2026 at 7:06 am

    Are you sure that you’re sending a correct request? Reffering to RFC 2616, your last chunk should be empty to tell the receiver about the end of the transmission. Just adopt your request like that:

    ...
    4e CRLF
    {"event":{"data_source":"ANDROID","timestamp":1318283841768,"type":"LEAVING"}} CRLF
    0 CRLF
    CRLF
    

    You might think of switching from Transfer-Encoding to Content-Length as well.

    Transfer-Encoding is for streaming data. You may send several chunks of data without knowing their size in advance. You have to send an empty chunk to declare the transmission as completed.

    Content-Length just specifies the Length of the data you will send, so that the receiver knows when the transmission reached the end.


    Just in case you just forgot to paste that last chunk:

    Overridden?

    Did you override accidentally some of params, parameters, request_parameters, request? Why not try

    • request.params for the same value or

    • request.request_parameters for the actual content hash {:event => …} without the additional dispatch stuff

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to process data obtained from a run of diff to an instance
I'm trying to process incoming JSON/Ajax requests with Django/Python. request.is_ajax() is True on the
I'm trying to grab data from a JSON on an external site but the
I'm trying to process some JSON into a Java object using some beans and
I am trying to process a JSON response and generate HTML from it. I
I'm trying to upload a file using AJAX, process data in the file and
I'm trying to use PHP to process JSON and am having trouble parsing it
I am trying to process files one at a time that are stored over
I am trying to process an uploaded file in a Perl program, using CGI::Application.
I am trying to process a dimension using SQL Server 2005 Analysis Services .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.