diff --git a/doc/api/examples/ruby/example_1.rb b/doc/api/examples/ruby/example_1.rb index 5fc837c17..704ca8fb6 100644 --- a/doc/api/examples/ruby/example_1.rb +++ b/doc/api/examples/ruby/example_1.rb @@ -1,13 +1,16 @@ -require "http" +require "net/http" API_ENDPOINT = "https://demo.consulproject.org/graphql".freeze def make_request(query_string) - HTTP.headers("User-Agent" => "Mozilla/5.0", accept: "application/json") - .get( - API_ENDPOINT, - params: { query: query_string.delete("\n").delete(" ") } - ) + uri = URI(API_ENDPOINT) + uri.query = URI.encode_www_form(query: query_string.delete("\n").delete(" ")) + request = Net::HTTP::Get.new(uri) + request[:accept] = "application/json" + + Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |https| + https.request(request) + end end query = <<-GRAPHQL diff --git a/doc/api/examples/ruby/example_2.rb b/doc/api/examples/ruby/example_2.rb index 859ee991d..e81c7b882 100644 --- a/doc/api/examples/ruby/example_2.rb +++ b/doc/api/examples/ruby/example_2.rb @@ -1,13 +1,17 @@ -require "http" +require "net/http" +require "json" API_ENDPOINT = "https://demo.consulproject.org/graphql".freeze def make_request(query_string) - HTTP.headers("User-Agent" => "Mozilla/5.0", accept: "application/json") - .get( - API_ENDPOINT, - params: { query: query_string.delete("\n").delete(" ") } - ) + uri = URI(API_ENDPOINT) + uri.query = URI.encode_www_form(query: query_string.delete("\n").delete(" ")) + request = Net::HTTP::Get.new(uri) + request[:accept] = "application/json" + + Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |https| + https.request(request) + end end def build_query(options = {})