0

I want to send a http post request in ruby for this :

body='{    
"request": {    
  "branch":"master"    
}}'

curl -s -X POST \

  -H "Content-Type: application/json" \
  -H "Accept: application/json" \    
  -H "Travis-API-Version: 3" \    
  -H "Authorization: token smEOuqMAAUcwLHBnFjnJkA" \

 -d "$body" \

 https://api.travis-ci.org/repo/shahsaurabh0605%2Fdaru/requests 

How do I do it?

reza.cse08
  • 5,938
  • 48
  • 39
Saurabh Shah
  • 576
  • 1
  • 5
  • 19
  • 1
    http://docs.ruby-lang.org/en/2.3.0/Net/HTTP.html#class-Net::HTTP-label-POST – pmichna Jun 06 '16 at 11:54
  • Why do we use `http.use_ssl = true` `http.verify_mode = OpenSSL::SSL::VERIFY_NONE`? Do I need to use this here? – Saurabh Shah Jun 06 '16 at 12:10
  • Also, what should I do if there are multiple headers? – Saurabh Shah Jun 06 '16 at 12:15
  • To validate https / ssl properly, you need http.use_ssl = true. If using this, you should NOT do http.verify_mode = OpenSSL::SSL::VERIFY_NONE but rather http.verify_mode = OpenSSL::SSL::VERIFY_PEER passing it a CA cert properly. VERIFY_NONE is just a workaround to bypass https ca verification. – Sam Jun 06 '16 at 15:38
  • I found this tool today: https://jhawthorn.github.io/curl-to-ruby/ – pmichna Jun 07 '16 at 08:05

0 Answers0