# Post\_form not posting to full url

**URL:** <https://www.ruby-forum.com/t/post-form-not-posting-to-full-url/108219>\
**Category:** Ruby\
**Created:** [June 30, 2007, 7:17am UTC](https://www.ruby-forum.com/t/post-form-not-posting-to-full-url/108219 "2007-06-30T07:17:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![putterson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecae2f/32.png) [@putterson](https://www.ruby-forum.com/u/putterson)\
**Post date:** [June 30, 2007, 7:17am UTC](https://www.ruby-forum.com/t/post-form-not-posting-to-full-url/108219/1 "2007-06-30T07:17:10Z")

</div>

I am using Net::HTTP.post\_form to post this form information:  
{ “form\_action” =\> “pet.do\_fight”, “mcid” =\> “9”, “level” =\> “30”,  
“type” =\> “fightmonster” }  
to this url:  
[http://neo2.hotornot.com/facebook/pet/?fb\_sig\_in\_iframe=1&fb\_sig\_time=1183152280.7875&fb\_sig\_user=502275480&fb\_sig\_profile\_update\_time=1182829280&fb\_sig\_session\_key=4ca41050eb103deabc95c2c5-502275480&fb\_sig\_expires=0&fb\_sig\_api\_key=692cc73d766279a46f0aaac1d104771e&fb\_sig\_added=1&fb\_sig=c9a69599141dd3a1f4b81f46fc52ffb2&cpid=560252&msg=](http://neo2.hotornot.com/facebook/pet/?fb_sig_in_iframe=1&fb_sig_time=1183152280.7875&fb_sig_user=502275480&fb_sig_profile_update_time=1182829280&fb_sig_session_key=4ca41050eb103deabc95c2c5-502275480&fb_sig_expires=0&fb_sig_api_key=692cc73d766279a46f0aaac1d104771e&fb_sig_added=1&fb_sig=c9a69599141dd3a1f4b81f46fc52ffb2&cpid=560252&msg=)  
and while it should be posting to this url when I used a packet sniffer  
(because it was not working) it showed me that it was posting only to  
this url:  
[http://neo2.hotornot.com/facebook/pet/](http://neo2.hotornot.com/facebook/pet/)  
it gives me a 404:

.msg404 { font-family:Arial,sans-serif; font-size:24px; text-align:center; }
Sorry! This page cannot be found
as well as giving me: # ...what am i doing wrong: ------------------- require 'net/http' require 'uri' spooform = { "form\_action" =\> "pet.do\_fight", "mcid" =\> "9", "level" =\> "30", "type" =\> "fightmonster" } fightit = "http://neo2.hotornot.com/facebook/pet/?fb\_sig\_in\_iframe=1&fb\_sig\_time=1183152280.7875&fb\_sig\_user=502275480&fb\_sig\_profile\_update\_time=1182829280&fb\_sig\_session\_key=4ca41050eb103deabc95c2c5-502275480&fb\_sig\_expires=0&fb\_sig\_api\_key=692cc73d766279a46f0aaac1d104771e&fb\_sig\_added=1&fb\_sig=c9a69599141dd3a1f4b81f46fc52ffb2&cpid=560252&msg=" responce = Net::HTTP.post\_form(URI.parse(fightit),spooform) puts responce -------------------

---

<div class="post-metadata">

**Author:** ![putterson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecae2f/32.png) [@putterson](https://www.ruby-forum.com/u/putterson)\
**Post date:** [July 1, 2007, 12:49am UTC](https://www.ruby-forum.com/t/post-form-not-posting-to-full-url/108219/2 "2007-07-01T00:49:24Z")

</div>

On 6/30/07, Pat G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ------------------- require 'net/http' require 'uri' spooform = { "form\_action" =\> "pet.do\_fight", "mcid" =\> "9", "level" =\> "30", "type" =\> "fightmonster" } fightit = "http://neo2.hotornot.com/facebook/pet/?fb\_sig\_in\_iframe=1&fb\_sig\_time=1183152280.7875&fb\_sig\_user=502275480&fb\_sig\_profile\_update\_time=1182829280&fb\_sig\_session\_key=4ca41050eb103deabc95c2c5-502275480&fb\_sig\_expires=0&fb\_sig\_api\_key=692cc73d766279a46f0aaac1d104771e&fb\_sig\_added=1&fb\_sig=c9a69599141dd3a1f4b81f46fc52ffb2&cpid=560252&msg=" responce = Net::HTTP.post\_form(URI.parse(fightit),spooform) puts responce

this source for post\_form (copied from [ruby-doc.org](http://ruby-doc.org)):

def HTTP.post\_form(url, params)  
req = Post.new(url.path)  
req.form\_data = params  
req.basic\_auth url.user, url.password if url.user  
new(url.host, url.port).start {|http|  
http.request(req)  
}  
end

You can see that it doesn’t send Uri#query.

Try either joining the GET parameters with POST ones, and send them  
all as POST params, or use Http#post and specify the path and query  
string.

uri = URI.parse(‘http://…’)  
i.e. Http.open(uri.host) do |http|  
response = http.post(uri.path + ‘?’ + uri.query, )  
end

you’d need to find out how to encode the form data.

Disclaimer: It’s 1AM here, I have not tested anything, so take these  
as ideas to investigate…

J.
