A modern browser is required for security, reliability, and performance. Contact us.

Aug 17 2012

Make Node.js PUT or POST requests compatible with Rails

Maybe it’s a “duh” moment or an amateur mistake but I could not find this information anywhere. To make a PUT or POST request in Node.js you need to stringify your parameters, place them in the body, and make sure to put

{'content-type': 'application/x-www-form-urlencoded'}

in your headers.

Without that last bit, Rails will not parse the body and your params hash will be empty.

Many Bothans died to bring us this information.

—Aaron Rosenberg