Ask A Question


You’re not receiving notifications from this thread.

Make http POST request that return xml response

elian asked in Rails

I want to make a http POST request that parse XML response and return the value of SessionId field that is inside XML. This is what I tried so far but I want to return SessionId filed that arrives with the response and I don't know if this is the right approach to have a xml response.
Ps: is there a way I can run this class from the console, in the way that I can see the response?

class Documents::CreateSession

def initialize()
@username = Rails.secrets.legal_doc.username
@password= Rails.secrets.legal_doc.password

def start

require "net/http"
require "uri"

uri = URI.parse("")

http =, uri.port)

request =
request.set_form_data({"userid" => @username, "password" => @password})

response = http.request(request)




You can run that code in the console by running the same code as you would in your app. response =

The response will be the return value of start as it currently is setup.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 80,973+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.