Forum: Ruby Get and Post Combined ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
32ba8c5c148da2653028dc7f8066b810?d=identicon&s=25 Doug Bromley (ashiro)
on 2006-05-23 23:14
(Received via mailing list)
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
62002cee15efcf4628cd7efc19425a07?d=identicon&s=25 Tim Becker (Guest)
on 2006-05-24 00:23
(Received via mailing list)
> #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
32ba8c5c148da2653028dc7f8066b810?d=identicon&s=25 Doug Bromley (ashiro)
on 2006-05-24 00:32
(Received via mailing list)
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.
#---------------------------------------------------------------------------------------------------
62002cee15efcf4628cd7efc19425a07?d=identicon&s=25 Tim Becker (Guest)
on 2006-05-24 00:55
(Received via mailing list)
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
C0cb3aadb9a66d00df16686f4a1fc312?d=identicon&s=25 Tim Uckun (Guest)
on 2006-05-24 11:50
(Received via mailing list)
use sockspy. It's invaluable for stuff like this.

BTW is there a ruby version of sockspy?
32ba8c5c148da2653028dc7f8066b810?d=identicon&s=25 Doug Bromley (ashiro)
on 2006-05-24 12:45
(Received via mailing list)
I didn't think it would be possible to sniff it with it being SSL?
32ba8c5c148da2653028dc7f8066b810?d=identicon&s=25 Doug Bromley (ashiro)
on 2006-05-24 12:51
(Received via mailing list)
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.
This topic is locked and can not be replied to.