我需要基于用户在表单上的输入来发送发布请求,因此控制器接收表单输入,然后根据输入通过Unirest发送发布请求。问题是服务器未收到发送的json参数。
我尝试将发布请求发送到https://postman-echo.com/post,事实证明,即使我已指定内容类型
replay = {
'access_token' => admin_access_token,'query' => phone_number
}.to_json
response = Unirest.post('https://postman-echo.com/post',headers: {
'accept' => 'application/json','Content-Type' => 'application/json'
},parameters: replay)
我希望数据不为空,应该为参数
{
"args"=>{},"data"=>"","files"=>{},"form"=>{},"headers"=>
{
"x-forwarded-proto"=>"https","host"=>"postman-echo.com","content-length"=>"0","accept"=>"*/*","accept-encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3","content-type"=>"application/x-www-form-urlencoded","headers"=>"{\"accept\"=>\"application/json\",\"Content-Type\"=>\"application/json\"}","parameters"=>"{\"access_token\":\"dummy_access_token\",\"query\":\"my_phone_number\"}","user-agent"=>"unirest-ruby/1.0","x-forwarded-port"=>"443"},"json"=>nil,"url"=>"https://postman-echo.com/post"
}
}