elian

Joined

50 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Make http POST request that return xml response

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
end

def start

require "net/http"
require "uri"

uri = URI.parse("http://example.com/search")

http = Net::HTTP.new(uri.host, uri.port)

request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data({"userid" => @username, "password" => @password})

response = http.request(request)

end

end

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.