Created
September 25, 2018 18:21
-
-
Save RenatoRosaFranco/eda47d1985733e7e0995b8365cf7a0af to your computer and use it in GitHub Desktop.
Exemplo de Net::HTTP ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'net/https' | |
require 'uri' | |
require 'pp' | |
xml = <<-HEREDOC | |
documento xml | |
HEREDOC | |
uri = URI.parse('urldohost') | |
@headers = { 'headers' } | |
resp, body = Net::HTTP.post(uri, xml, @headers) | |
result = JSON.parse(resp.body) | |
if ( resp.code == "201" ) then | |
p result | |
else | |
puts "Resposta quando a solicitação não for válida : \n" | |
puts result['message'] | |
end | |
puts "\nResposta: ", resp | |
puts body | |
pp uri.host | |
pp @headers | |
pp resp | |
pp xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment