2

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?

fivedigit
  • 18,464
  • 6
  • 54
  • 58

1 Answers1

1

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

Andy Jeffries
  • 392
  • 3
  • 15