I can get the parameters set properly and make the call to the server:
params = {‘dst’ => ‘RES’, ‘id’ => ‘1’, ‘type’ => “11”}
uri = URI(‘http://url:8081/set.cgi’)
res = Net::HTTP.post_form(uri, params)
But I can’t seem to add on the hex values.
Does anyone have some suggestions? It seems like I may need to go lower
level than the ruby post. It seems to want to map all the parameters so
I can’t pass it a basic string.
Here’s some code that works in objective-C. I’m not that familiar with
objective-C but it looks to me like the body contains the parameters and
the hex data and the ruby map function is throwing me off.
Thanks for the reply. I have read and re-read the NET::HTTP docs and it
doesn’t do what I want because it was showing all the parameters as
hashes. I was trying to send three values as a hash and one as a string
and I couldn’t mash them together. I ended up figuring it out and I need
to create the url myself rather than using any of the ‘easy’ methods.
This is what ended up working:
data = “dst=#{dst}&type=#{type}&id=#{id}&#{data_array.join}”
resp, data = http.post(path, data)
p resp.body
I was looking at the examples higher up on the page. The POST and POST
with Multiple Values show the form values as hashes. I didn’t make it to
that part of the documentation. I guess I didn’t read it that well after
all!
Thanks for the link. I think I have a working solution now.
Shaun
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.