I'm using Postman to test an api. My local unit tests pass. But when I use the same request in Postman, I get
{
"errors": [
{
"detail": "Unsupported media type \"application/json\" in request.",
"status": "415",
"source": {
"pointer": "/data"
},
"code": "unsupported_media_type"
}
]
}
Using a breakpoint, get that result when unpacking request.data in the View.
I made sure to set application/json in the Content-Type header, and even specified it as a parser. I still get the error. Can you see why?
Part of the code where things break:
class ProvisionCustomerView(APIView):
permission_classes = [IsAuthenticated]
serializer_class = ProvisionCustomerSerializer
def post(self, request):
customer_data = request.data
When using postman, request.data returns:
*** rest_framework.exceptions.UnsupportedMediaType: Unsupported media type "application/json" in request.
Although it works fine in a unit test.


