Hello,
I had this post on the Ruby channel, but maybe I have more luck here :)
I'm struggling with the last piece of the puzzle here. Basically I want
to reuse a cookie that I capture from a previous RestClient.post()
login, the only problem is that the second RestClient.post will not
accept it. I have tried different methods to pass the cookie value to
the RestClient.post(), but with no success. Also tried the base64
encoding, also failed here. Can someone please advice?
Code:
=========================================require 'json'
require 'rest-client'
url_login = 'http://192.168.1.51/cms/v1/login/login'
url_adduser= 'http://192.168.1.51/cms/v1/config/records'
payload_login = <<-JSON
{
  "login":
  {
   "username":"user-1",
   "password":"secret",
  }
}
JSON
payload_adduser= <<-JSON_ADDUSER
  {
    "adduser":
    {
     "name":"cms-users-2",
    }
  }
JSON_ADDUSER
initheader_login = {'Content-Type' =>
'application/x-www-form-urlencoded',:accept => :json}
initheader_add_user= {'Content-Type' =>
'application/x-add-user'}
#the restexec_login goes well, I can see it login on the webserver (code
201)
restexec_login RestClient.post(url_login,payload_login,initheader_login)
#capture the cookie as a result of the execution of restexec_login
query_cookie = restexec_login.cookies
cookie_hash = query_cookie['SESSION_ID']
cookie = {:SESSION_ID => cookie_hash}
#the second post (below) will fail because of the missing cookie
variable
restexec_adduserRestClient.post(url_adduser,payload_adduser,initheader_add_user)
END CODE
=============
How can I pass the cookie in the second post method?
Thanks in advance!
Kind Regards,
iLias
-- 
Posted via http://www.ruby-forum.com/.
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/1e0ce4332dcf5bddae1395dc51d5dd06%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.