Raise 400 JSONBadRequest instead of KeyError - Fixes #686

Please see issue #686.