【发布时间】:2017-01-13 14:30:40
【问题描述】:
我必须在 httparty 中发送一个 post 请求并获得响应 我的 json 参数是
{
"webhook": {
"topic": "shop/update",
"address": "http://2350d6c0.ngrok.io/shopify_stores/update_shop_info",
"format": "json"
}
}
我使用 httparty 参数作为
begin
response = HTTParty.post("#{url}",
{
:body => [
{
"webhook" => {
"topic" => "shop\/update",
"address" => "http:\/\/15ec3a12.ngrok.io\/shopify_stores\/update_shop_info", #place your url here
"format" => "json"
}
}
].to_json,
:headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
})
byebug
rescue HTTParty::Error
end
但它的反应是
必填参数缺失或无效
【问题讨论】:
-
好的。控制器中有没有在
privatesection 下显示def something_params的部分?如果是这样,你能把它放在你的问题中吗? -
我不使用它们只是向服务器发送一个发布请求并保存响应
标签: ruby-on-rails json httparty