-4

What is the equivalent ruby code for the following python code. I surfed net and find net/http' is the correct method. But I am new to ruby, I am unable to use this method effectively. Can anybody help me to write this in python?

Python

url = "https://www.abcde.com/api/"
post_data = "method=a&rate=2&order=asc"
headers =  {"key"=>"55208252", "sign"=>"4589cab68921fb43ad53149ea625e29"}

url_request_object = urllib2.Request(url, post_data, headers)

response = urllib2.urlopen(url_request_object)
fidato
  • 719
  • 5
  • 22
Sam
  • 5,040
  • 12
  • 43
  • 95

1 Answers1

1

Signature of correspondent method is the same

http = Net::HTTP.new('localhost', 3000)
headers = {'Content-Type' =>  'application/json'}
data = {:test => 'test'}

resp, data = http.post(path, data.to_json, headers)
Pavel S
  • 1,543
  • 8
  • 14