title: Rails: Can't verify CSRF token authenticity when making a POST request
body: <p>I want to make <code>POST request</code> to my local dev, like this:</p>
  
  <pre><code>  HTTParty.post('http://localhost:3000/fetch_heroku',
                  :body =&gt; {:type =&gt; 'product'},)
  </code></pre>
  
  <p>However, from the server console it reports </p>
  
  <pre><code>Started POST "/fetch_heroku" for 127.0.0.1 at 2016-02-03 23:33:39 +0800
    ActiveRecord::SchemaMigration Load (0.0ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  Processing by AdminController#fetch_heroku as */*
    Parameters: {"type"=&gt;"product"}
  Can't verify CSRF token authenticity
  Completed 422 Unprocessable Entity in 1ms
  </code></pre>
  
  <p>Here is my controller and routes setup, it's quite simple. </p>
  
  <pre><code>  def fetch_heroku
      if params[:type] == 'product'
        flash[:alert] = 'Fetch Product From Heroku'
        Heroku.get_product
      end
    end
  
    post 'fetch_heroku' =&gt; 'admin#fetch_heroku'
  </code></pre>
  
  <p>I'm not sure what I need to do? To turn off the CSRF would certainly work, but I think it should be my mistake when creating such an API.</p>
  
  <p>Is there any other setup I need to do?</p>