Reputation: 259
I am trying to use HTTParty in irb to test an API call, but I keep getting a 401. Attempts to do a get
against the same URL with the same header info using the Postman Chrome add-on work fine -- any ideas?
irb> HTTParty.get("https://developer.fingercheck.com/api/v1/Employees/GetAllEmployees",
:headers => {"APIKEY" => "ABCD1234-1234-ABCD-EFGH-ABCD1234ABCD123",
"ClientSecretKey" => "ABCD1234-1234-ABCD-EFGH-ABCD1234ABCD123",
"Content-Type" => "application/json"})
=> <HTTParty::Response:0x8 parsed_response=nil, @response=#<Net::HTTPUnauthorized 401 Unauthorized readbody=true>,
@headers={"cache-control"=>["no-cache"], "pragma"=>["no-cache"],
"expires"=>["-1"], "server"=>["Microsoft-IIS/7.5"], "x-aspnet-version"=>["4.0.30319"],
"x-powered-by"=>["ASP.NET"], "date"=>["Mon, 01 Dec 2014 21:04:32 GMT"],
"connection"=>["close"], "content-length"=>["0"]}>
I have also tried to do the get
call with :query=>...
, :query => {:header...
, and :basic_auth =>...
, but none change the results. Any ideas?
I know a fair number of HTTParty questions have been asked and answered, but I didn't see anything that spoke to this particular issue.
The documentation I know of for the API is at http://developer.fingercheck.com/api/help
Upvotes: 0
Views: 423
Reputation: 259
The error turned out to be a problem with the API, not with the code -- our headers were being read as 'Apikey' and 'Clientsecretkey' and therefore failing some equality on their side. A fix was pushed to production by them, code now functional.
Upvotes: 1