Im trying to add headers to my api call
Heres what i have tried at the moment
api1 = HTTParty.get(URI.encode('apiurllink' + tmname + '&date=' + fromdate + ' TO ' + todate + '', :headers => {"Authorization" => "Bearer apikey"})).parsed_response
This is returning this error
TypeError: no implicit conversion of Hash into String
How do I fix this?
Your attempt is raising a TypeError since you are passing the
:headers => {"Authorization" => "Bearer apikey"}
hash toURI.encode
and not HTTParty.get.A better way is to use the
query
option and get HTTParty to construct the query string for you.