Invalid put requests with Accept not set to json cause 500 error

I've attached a fix and a test that exposes the original problem.