我已经成功地通过使用POST方法API这样创造了新的纪录(使用Curl::PostField
)导轨无法验证CSRF令牌真实性
curl_post_fields = [
Curl::PostField.content('first_name', first_name),
Curl::PostField.content('last_name', last_name),]
contact = Curl::Easy.http_post("#{ENV['API_V1_URL']}/contacts", *curl_post_fields)
contact.ssl_verify_peer = false
contact.http_auth_types = :basic
contact.username = ENV['API_V1_USERNAME']
contact.password = ENV['API_V1_PASSWORD']
contact.perform
response = JSON.parse(contact.body_str)
但是当我通过补丁像这样的更新记录(使用JSON请求参数):
contact = Curl.patch("#{ENV['API_V1_URL']}/contacts/#{qontak_id}",{:email => email, :gender_id => 8})
contact.ssl_verify_peer = false
contact.http_auth_types = :basic
contact.username = ENV['API_V1_USERNAME']
contact.password = ENV['API_V1_PASSWORD']
contact.perform
response = JSON.parse(contact.body_str)
我得到了来自服务器的一些错误
Can't verify CSRF token authenticity
Filter chain halted as :authenticate rendered or redirected
我也有CSRF protect_from_forgery with: :null_session
有可能使用Curl::PostField
自动包括csrf token
还是有像patch or put method
Curl::Postfield
任何类似的方式关闭?
嗨,大家好,我仍然坚持这一点,请帮忙吗? –