Reputation: 231
I want to know the status of my API call
when its success
.
begin
@project = Project.find( id: '22', authorization: @auth )
rescue ActiveRestClient::HTTPClientException, ActiveRestClient::HTTPServerException => e
Rails.logger.error("Project find returned #{e.status} #{e.message}")
end
When my API fails to get a project
with an id '22'
, i get the status
and the message as exception. But how can i get the status 200
when its a success
call.
Upvotes: 1
Views: 278
Reputation: 402
From memory, you can access the HTTP status of a response object using simply:
@project._status
https://github.com/whichdigital/active-rest-client/blob/master/lib/active_rest_client/base.rb#L10
I was the main author of this project, although I no longer work for Which so am not really responsible for its future direction. Feel free to ask any other questions.
Upvotes: 0