user8745303
user8745303

Reputation: 39

ActiveRestClient respond to 204 No Content

I have a before_request for all ActiveRestClient calls, but the server is responding with a 204 No Content on some actions. This causes an error:

MultiJson::LoadError in FilesController#update 795: unexpected token at ''

This is the before_request:

before_request do |name, request|
  request.headers["Accept"] = 'application/json'
  request.headers["Content-Type"] = 'application/json'
end

How can I accept some responses to be no content when using ActiveRestClient?

Upvotes: 2

Views: 240

Answers (1)

Andy Jeffries
Andy Jeffries

Reputation: 402

I see you've already committed a patch back to the project. I fixed it a different way, I added after_filter functionality to match the existing before_filter functionality. This allows you to change responses globally (if you have your own Base object), or for a specific response. My PR is at:

https://github.com/whichdigital/active-rest-client/pull/70

You can see an example of how to use it at my fork (because my push access has been revoked for some reason):

https://github.com/andyjeffries/active-rest-client#using-filters

Upvotes: 1

Related Questions