# Using ruby to submit an http form - either im confused

**URL:** <https://www.ruby-forum.com/t/using-ruby-to-submit-an-http-form-either-im-confused/90467>\
**Category:** Rails\
**Created:** [March 29, 2007, 1:06am UTC](https://www.ruby-forum.com/t/using-ruby-to-submit-an-http-form-either-im-confused/90467 "2007-03-29T01:06:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dissolved](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b3f665/32.png) [@dissolved](https://www.ruby-forum.com/u/dissolved)\
**Post date:** [March 29, 2007, 1:06am UTC](https://www.ruby-forum.com/t/using-ruby-to-submit-an-http-form-either-im-confused/90467/1 "2007-03-29T01:06:59Z")

</div>

Hi All:

I have a rails application (we’ll call it ‘FrontApp’)that is using REST  
routes. I have tested this with curl and its behaves as expected.

I also have a second independent rails application on the same server.  
Also using REST routes. (we’ll call this app ‘BackApp’).

I want to beable to call and submit a form in BackApp from FrontApp and  
I think im going about it the wrong way. Should I be using web service  
apis on BackApp and simply invoking the service calls from FrontApp or  
can i (and it is good design) to try and post the form in BackApp from  
FrontApp?

Below is a snippet of a test script ive been using to attempt to post  
the above mentioned form in BackApp using ruby. All i get back is the  
details of the form but the event (an email sent) is not occurring as if  
i were submitting the form in the BackApp application.

Net::HTTP.new(‘[backapp.mydomain.com](http://backapp.mydomain.com)’, 80).start do |http|

test\_email\_req = Net::HTTP::Post.new(‘/notification/email\_request’)  
test\_email\_lic\_req.set\_form\_data(‘email\_request[email\_request]’=\>‘removed\_email\_address@domain.invalid’)  
test\_email\_req.add\_field ‘Accept’, ‘application/xml’

response = http.request(test\_email\_req)

case response  
when Net::HTTPSuccess  
puts “Code: #{response.code}”  
puts “Message: #{response.message}”  
puts “Body:\n #{response.body}”  
else  
# Throw exception  
response.error!  
end  
end

any help would be appreciated  
Thanks  
Ryan
