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?
#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_adduser=
RestClient.post(url_adduser,payload_adduser,initheader_add_user)
END CODE
How can I pass the cookie in the second post method?
Setting verbose to true will print the http post request to your
terminal, so that you can compare it with what the server expects. Also,
check whether you need 'Cookie: ’ or 'Set-Cookie: '.
Thanks for sticking around, curl show me indeed more information with
the verbose mode. The cookie stuff didn’t work eventually, I think duo
the fact that the cookies was expired or so.
I found within the API another way to authenticate, with headers, so
this is working oke for now
Thanks for your support, it was very helpful!
Kind Regards,
iLias
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.