Tyler Horan
Tyler Horan

Reputation: 53

How can I run this curl command in Ruby?

curl --request PROPFIND --url "http://carddav.mail.aol.com/home/[email protected]/Contacts/" --header "Content-Type: text/xml" --header "Depth: 1" --data '<A:propfind xmlns:A="DAV:"><A:prop><A:getetag /><D:address-data xmlns:D="urn:ietf:params:xml:ns:carddav"/></A:prop></A:propfind>' --header "Authorization: Bearer fjskdlfjds"

Is there a particular method in Net::HTTP that allows the propfind command?

Upvotes: 3

Views: 584

Answers (1)

B Seven
B Seven

Reputation: 45941

Net::HTTP::Propfind

Here is an example:

uri = URI.parse('http://example.com')
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Propfind.new(uri.request_uri)

# Set your body (data)
request.body = "Here's the body."

# Set your headers: one header per line.
request["Content-Type"] = "application/json"

response = http.request(request)

Upvotes: 2

Related Questions