# Get and Post Combined?

**URL:** <https://www.ruby-forum.com/t/get-and-post-combined/61419>\
**Category:** Ruby\
**Created:** [May 23, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/get-and-post-combined/61419 "2006-05-23T23:14:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@ashiro](https://www.ruby-forum.com/u/ashiro)\
**Post date:** [May 23, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/get-and-post-combined/61419/1 "2006-05-23T23:14:05Z")

</div>

Hello

I’ve got a bit of a problem interacting with the Overture (now YSM) API  
and  
I’m getting quite desperate for some help.

Basically I need to ‘post’ form data to a path containing get variables.  
Unfortunately I can’t go into details about the API as its held under an  
NDA  
for some strange reason but please try and help from some of this  
similar  
code:  
#---------------------------------------------------------------------------------------------------  
host = “[secure.ysm1.com](http://secure.ysm1.com)”  
port = 443  
now = Date::today()  
yday = @now - 1

#The path with its get variables  
path = “/index.jhtml?\_ARGS=/index.jhtml”

xml = “XML Encoded POST Data”

site = Net::HTTP.new(@host, 443)  
site.use\_ssl = true  
enc\_text = “xml=” \<\< CGI.escape(@xml)

resp, data = site.post(URI.parse  
(@full\_path),enc\_text,{“Content-Type”=\>“application/x-www-form-urlencoded”})

puts data # Should print XML formatted result but instead displays  
route  
of that server (the form HTML) as if no data was sent.  
#---------------------------------------------------------------------------------------------------  
When I try using this class, rather than getting the XML reply I get the  
HTML form located at the servers route. Which is as if the get  
variables in  
the path are being shaved off and its failing to post the data  
correctly.  
As you can see I also have to use the service over SSL and send a header  
for  
the content-type.

I’d be extremely greatful if anyone can shed any light because I’m going  
mad. I’ve searched on Google and the groups to no avail so I’m all  
ears.

Many thanks for reading.

Doug

---

<div class="post-metadata">

**Author:** ![ashiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@ashiro](https://www.ruby-forum.com/u/ashiro)\
**Post date:** [May 24, 2006, 12:23am UTC](https://www.ruby-forum.com/t/get-and-post-combined/61419/2 "2006-05-24T00:23:07Z")

</div>

> #The path with its get variables  
> path = “/index.jhtml?\_ARGS=/index.jhtml”

Called `path` here…

…

> site = Net::HTTP.new(@host, 443)  
> enc\_text = “xml=” \<\< CGI.escape(@xml)
> 
> resp, data = site.post(URI.parse  
> (@full\_path),enc\_text,{“Content-Type”=\>“application/x-www-form-urlencoded”})

and `@full_path` here. Are you sure it’s the same variable?  
-tim

---

<div class="post-metadata">

**Author:** ![ashiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@ashiro](https://www.ruby-forum.com/u/ashiro)\
**Post date:** [May 24, 2006, 12:32am UTC](https://www.ruby-forum.com/t/get-and-post-combined/61419/3 "2006-05-24T00:32:51Z")

</div>

Hell. Apologies. Thats a typo.  
The variables are the same.

#---------------------------------------------------------------------------------------------------  
host = “[secure.ysm1.com](http://secure.ysm1.com)”  
port = 443  
now = Date::today()  
yday = @now - 1

#The path with its get variables  
path = “/index.jhtml?\_ARGS=/index.jhtml”

xml = “XML Encoded POST Data”

site = Net::HTTP.new(@host, 443)  
site.use\_ssl = true  
enc\_text = “xml=” \<\< CGI.escape(@xml)

resp, data = site.post  
(path,enc\_text,{“Content-Type”=\>“application/x-www-form-urlencoded”})

puts data # Should print XML formatted result but instead displays  
route  
of that server (the form HTML) as if no data was sent.  
#---------------------------------------------------------------------------------------------------

---

<div class="post-metadata">

**Author:** ![ashiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@ashiro](https://www.ruby-forum.com/u/ashiro)\
**Post date:** [May 24, 2006, 12:55am UTC](https://www.ruby-forum.com/t/get-and-post-combined/61419/4 "2006-05-24T00:55:11Z")

</div>

Is the server under your control? Can you be certain that the server  
isn’t just returning the form even though you’re posting data? My next  
step would be to check what actually gets sent to the server using a  
sniffer.  
-tim

---

<div class="post-metadata">

**Author:** ![ashiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@ashiro](https://www.ruby-forum.com/u/ashiro)\
**Post date:** [May 24, 2006, 12:45pm UTC](https://www.ruby-forum.com/t/get-and-post-combined/61419/5 "2006-05-24T12:45:46Z")

</div>

I didn’t think it would be possible to sniff it with it being SSL?

---

<div class="post-metadata">

**Author:** ![ashiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@ashiro](https://www.ruby-forum.com/u/ashiro)\
**Post date:** [May 24, 2006, 11:50am UTC](https://www.ruby-forum.com/t/get-and-post-combined/61419/6 "2006-05-24T11:50:39Z")

</div>

use sockspy. It’s invaluable for stuff like this.

BTW is there a ruby version of sockspy?

---

<div class="post-metadata">

**Author:** ![ashiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e5b9ba/32.png) [@ashiro](https://www.ruby-forum.com/u/ashiro)\
**Post date:** [May 24, 2006, 12:51pm UTC](https://www.ruby-forum.com/t/get-and-post-combined/61419/7 "2006-05-24T12:51:55Z")

</div>

I’m going to try and use ‘http-access2’ as it mentions in the docs that  
it  
attempts to recreate Perls LWP library in Ruby. Its the LWP Overture  
use in  
their example Perl script.

I’ll keep you posted.
