i can get response from API using curl like this:
curl -X GET https://myapi.com/... -H "client_id: my_id" -H "client_secret: my_secret"
but when i send requests with HTTParty:
response = HTTParty.get(url, headers: {"client_id" => "my_id", "client_secret" => "my_secret"})
the result is:
#<HTTParty::Response:0x55e5db898160 parsed_response="Unable to retrieve client_id from message",
@response=#<Net::HTTPUnauthorized 401 Unauthorized readbody=true>, @headers={"cache-control"=>["no-cache"], "pragma"=>["no-cache"], "content-length"=>["41"], "content-type"=>["text/plain"], "expires"=>["-1"], "server"=>["Microsoft-IIS/8.5"], "strict-transport-security"=>["max-age=31536000; includeSubdomains;"], "x-aspnet-version"=>["4.0.30319"], "x-powered-by"=>["ASP.NET"], "access-control-allow-origin"=>["*"], "access-control-allow-credentials"=>["true"], "access-control-allow-headers"=>["*"], "access-control-allow-methods"=>["GET, POST, PUT, DELETE, OPTIONS"], "date"=>["Wed, 13 Apr 2022 08:56:56 GMT"], "connection"=>["close"]}>
and output from response.request is:
#<HTTParty::Request:0x000055e5db897120 @changed_hosts=false, @credentials_sent=false, @http_method=Net::HTTP::Get,
@options={:limit=>5, :assume_utf16_is_big_endian=>true, :default_params=>{}, :follow_redirects=>true, :parser=>HTTParty::Parser, :uri_adapter=>URI, :connection_adapter=>HTTParty::ConnectionAdapter, :headers=>{"client_id"=>"my_id", "client_secret"=>"my_secret"}},
@path=#<URI::HTTP http://my_api.com/...>, @last_uri=#<URI::HTTP http://my_api.com/...>, @raw_request=#<Net::HTTP::Get GET>, @last_response=#<Net::HTTPUnauthorized 401 Unauthorized readbody=true>>
my opinion is, the headers goes in @options parameter instead of @headers, so request can't find my client_id. Does anyone know how can i fix this?