I am able to get successful response from AWS V4 API with api key using CURL with syntax:
curl --location 'https://api.develop.com' \ --header 'x-api-key: api-key'
But when I implement the HTTP request for the same I get 401. Replaced actual URL with https://api.develop.com and actual api-key with api-key
require "uri"
require "net/http"
url = URI("https://api.develop.com")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = api_key
response = https.request(request)
Any suggestions about why a curl request is successful and the same request using Ruby HTTP libraries return 401.
I haven’t faced an issue like this before. I have tried the same request using Net::HTTp, HTTParty and RestClient in ruby.