Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.07 KB | None | 0 0
  1. require 'net/http'
  2. require 'net/https'
  3.  
  4. # RP - PWOD Duplicate (POST )
  5. def send_request
  6.   uri = URI('https://renaissanceperiodization.com/api/product_templates')
  7.  
  8.   # Create client
  9.   http = Net::HTTP.new(uri.host, uri.port)
  10.   http.use_ssl = true
  11.   http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  12.   data = {
  13.     "secret" => "fb0f3684e4ae332bf5fb070a9ea66c9c",
  14.     "template_type" => "diet",
  15.     "first_name" => "Don",
  16.     "last_name" => "Villareal",
  17.     "email" => "rp1@maildrop.cc",
  18.     "medical_waiver" => "yes",
  19.     "gender" => "male",
  20.     "current_weight" => "126",
  21.     "goal" => "fat loss",
  22.     "testmode" => "true",
  23.   }
  24.   body = URI.encode_www_form(data)
  25.  
  26.   # Create Request
  27.   req =  Net::HTTP::Post.new(uri)
  28.   # Add headers
  29.   req.add_field "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"
  30.   # Set body
  31.   req.body = body
  32.  
  33.   # Fetch Request
  34.   res = http.request(req)
  35.   puts "Response HTTP Status Code: #{res.code}"
  36.   puts "Response HTTP Response Body: #{res.body}"
  37. rescue StandardError => e
  38.   puts "HTTP Request failed (#{e.message})"
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement