diff --git a/swh/core/api/__init__.py b/swh/core/api/__init__.py --- a/swh/core/api/__init__.py +++ b/swh/core/api/__init__.py @@ -327,11 +327,14 @@ from flask import request @self.route('/'+meth._endpoint_path, methods=['POST']) + @negotiate(MsgpackFormatter) + @negotiate(JSONFormatter) @functools.wraps(meth) # Copy signature and doc def _f(): # Call the actual code obj_meth = getattr(backend_factory(), meth_name) - return encode_data_server(obj_meth(**decode_request(request))) + kw = decode_request(request) + return obj_meth(**kw) @deprecated(version='0.0.64', diff --git a/swh/core/api/tests/test_api.py b/swh/core/api/tests/test_api.py --- a/swh/core/api/tests/test_api.py +++ b/swh/core/api/tests/test_api.py @@ -37,9 +37,11 @@ return error_handler(exception, encode_data_server) client = WerkzeugTestClient(app, BaseResponse) - res = client.post('/test_endpoint_url', - headers={'Content-Type': 'application/x-msgpack'}, - data=b'\x81\xa9test_data\xa4spam') + res = client.post( + '/test_endpoint_url', + headers=[('Content-Type', 'application/x-msgpack'), + ('Accept', 'application/x-msgpack')], + data=b'\x81\xa9test_data\xa4spam') self.assertEqual(nb_endpoint_calls, 1) self.assertEqual(b''.join(res.response), b'\xa3egg')