A1aks
A1aks

Reputation: 186

Using Curl commands in Ruby on Rails 2

I am wanting to send some XML files over HTTP to a web service in post request. I have the generated XML files and would like to use the following command

curl -F "[email protected]" -F "[email protected]" \
     -F "[email protected]" https://www.somesite.com/submit

I have no clue how to incorporate the command in Rails 2.

Please could so one suggest me an idea or library that I could use for this purpose.

Cheers

Upvotes: 0

Views: 918

Answers (1)

gioele
gioele

Reputation: 10205

Use the Curb gem, it is a library that wraps cURL in Ruby objects and methods.

Have a look at the examples on http://taf2.github.com/curb/.

In your case you will have to use something like

submission_field = Curl::PostField.content(File.read('submission.xml'), 'SUBMISSION')
study_field = Curl::PostField.content(File.read('stydy.xml'), 'STUDY')

c = Curl::Easy.http_post("https://www.somesite.com/submit",
                         submission_field, study_field, ...)

Upvotes: 2

Related Questions