I'm trying to make an HTTP request using RestClient in Rails, but I'm encountering an issue with the headers. Here is the code I'm using:
headers = {
'Content-Type' => 'application/json',
'Authorization' => "Bearer 111",
'x-api-key' => "12354",
'Accept' => 'application/json;odata.metadata=minimal;odata.streaming=true'
}
params = {
method: method,
url: "#{@url}/#{path}",
headers: headers
}
request = RestClient::Request.new params
response = request.execute
if response.body.present?
JSON.parse(response.body)
else
{}
end
The issue is that when I make the request, the x-api-key header is automatically transformed into X-Api-Key. As a result, I receive a 403 response. The request works fine from Postman or cURL because the header key is not changed there.
Is there any way to prevent RestClient from modifying the header name and send it exactly as I write it?