Net/http rewrites the passed in headers e.g. x-api-key to X-Api-Key
To resolve this, make an ImmutableKey class
Example:
require "uri"
require "net/http"
url = URI("https://api.dassetx.com/api/markets/tickers")
class ImmutableKey < String
def capitalize
self
end
def to_s
self
end
alias_method :to_str, :to_s
end
request = Net::HTTP::Get.new(url)
request[ImmutableKey.new("x-account-id")] = "abc"
request[ImmutableKey.new("x-api-key")] = "xxx"
puts request
https = Net::HTTP.new(url.host, url.port)
https.set_debug_output($stdout)
https.use_ssl = true
response = https.request(request)
puts response.read_body
Comments
0 comments
Please sign in to leave a comment.