When i tried to post data through my REST Client ,i am getting a warning like this
Warning :Can't verify CSRF token authenticity.
How to solve this.
I believe you are trying to make a POST
from a link
. By default links
aren't supposed to make POST
requests, only GET
ones. So when you try to make the connection to your server, Rails
warns you about this.
One way to bypass this kind of behavior is, instead of using a link
, use a form
. So you can make proper POST
requests to the server.
Alternatively, you can remove the protect_from_forgery
line from your application_controller
, so Rails
doesn't do this kind of verification, but this is extremely not recommended.
You could do this, (but not recommended :)), skip forgery protection
Ex: you are posting data to PostController => Create action
class PostsController < ApplicationController
before_filter :protect_from_forgery, :except => [:create]
def create
#your method
end
end
but having said that, I'm sure there should be a better way to do what you want to do, so if you could explain what you want to do, someone could help
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With