concrete-datastore
concrete-datastore copied to clipboard
Fix UnsupportedMediaType
We are getting an error while dispatch on the API. The error received is an error 500 with a sentry.
When the error UnsupportedMediaType is raised, we have to return a response 400.
UnsupportedMediaType: Unsupported media type "" in request.
File "django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "rest_framework/viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "concrete_datastore/api/v1/views.py", line 1908, in dispatch
data = self.request.data
File "rest_framework/request.py", line 216, in data
self._load_data_and_files()
File "rest_framework/request.py", line 279, in _load_data_and_files
self._data, self._files = self._parse()
File "rest_framework/request.py", line 351, in _parse
raise exceptions.UnsupportedMediaType(media_type)