[英]How to create POST Request in Ruby
I have functionality where I need send delivery payload with static basic token and additional header.我有需要使用 static 基本令牌和附加 header 发送交付有效负载的功能。
scope = "xapi:read" # some require xapi:read, some require xapi:all
client_auth_header = "Basic <insert token here>"
client_version_header = "1.0.3"
client_site = "<Provided by client>"
I need to do this with post request我需要通过发布请求来执行此操作
curl --request GET \
--url https://client-url/data/xAPI/agents \
--header 'Authorization: Basic MjAHYBFHKKMHIKNBGRmOGM0M2RiMDg0M' \
--header 'X-Experience-API-Version: 1.0.3'
How do I write a post request in ruby?如何在 ruby 中编写发布请求?
with something like this像这样的东西
client.post("/xAPI/statements", body: data.to_json, headers: { "Content-Type" => "application/json" })
what should I replace the client with?我应该用什么替换客户端?
https://www.twilio.com/blog/5-ways-make-http-requests-ruby https://www.twilio.com/blog/5-ways-make-http-requests-ruby
Sending http post request in Ruby by Net::HTTP 通过 Net::HTTP 在 Ruby 中发送 http 发布请求
Check above, they might answer your question检查上面,他们可能会回答你的问题
The httparty gem supports a very similar API to what you described here, with HTTParty.post
. httparty gem支持与您在此处描述的非常相似的 API ,带有
HTTParty.post
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.