Get and Post Combined?


#1

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
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


#2

#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


#3

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

#---------------------------------------------------------------------------------------------------
host = “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.
#---------------------------------------------------------------------------------------------------


#4

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


#5

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


#6

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

BTW is there a ruby version of sockspy?


#7

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.