I am trying to just test my RESTful API with cURL. Using the following call:
curl -d "name=jimmy" -H "Content-Type: application/x-www-form-urlencoded" http://127.0.0.1:3000/people.xml -i
Rails is dying though:
ActionController :: InvalidAuthenticityToken (ActionController :: InvalidAuthenticityToken) :: 8: in `synchronize '
This seems to work through the protect_from_forgery filter. I thought protected_from_forgery was excluded for HTTP requests like HTTP POST / PUT / DELETE? This is clearly aimed at the XML format.
If I pass the actual XML content, it works. But my users will send POST data as URLs. I know all the different ways I can turn off_from_forgery protection, but what is the correct way to solve it? I want to leave it so that when I have HTML forms and process format.html, I remember to include it again. I want users to be able to make HTTP POST requests to my XML-based API, although they are not bombarded by this.
source
share