Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Rails uses <a href="http://guides.rubyonrails.org/security.html#csrf-countermeasures" rel="nofollow noreferrer">authenticity token</a> to prevent <a href="http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf" rel="nofollow noreferrer">CSRF</a>. It inserts special token calculated based on current user's session into every form and checks it when request comes to the server. </p> <p>When you perform POST request using curl you get that error as you're not passing valid authenticity token to the server. You can either disable that protection for you method like that (note, that disabling it will make this action vulnerable for CSRF):</p> <pre><code>protect_from_forgery :except =&gt; :some_action </code></pre> <p>or you can use some <a href="http://robots.thoughtbot.com/post/3035393350/curling-with-rails-authenticity-token" rel="nofollow noreferrer">ninja</a> <a href="http://www.maximporges.com/2011/03/02/using-curl-with-a-web-site-secured-by-rails-authenticity-token/" rel="nofollow noreferrer">magic</a> to pass valid authenticity token to the server.</p> <p>Another option is based on the fact that Rails checks authenticity token only for requests with certain content types. If it's an API and you're getting response in JSON you can try setting content type of the request to <code>application/json</code> like that:</p> <pre><code>curl -H "Content-Type: application/json" ... </code></pre> <p>See these links for more information: <a href="http://www.darianshimy.com/2009/10/invalidauthenticitytoken-error-in-rails/" rel="nofollow noreferrer">one</a>, <a href="https://stackoverflow.com/a/1608563/357743">two</a>, <a href="https://stackoverflow.com/a/349969/357743">three</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload