I applied something similar to a tutorial from the Django Rest Framework regarding this part:
def post(self, request, format=None):
serializer = SnippetSerializer(data=request.DATA)
if serializer.is_valid():
serializer.save()
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, headers=headers, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Now it works well on my computer (I get HTTP 201, the location of the resource is in the header, the body is valid JSON), both with debug = True or debug = False, but when I download it on my production server running Windows Azure, this The answer I get is:
<head>
<title>Document Moved</title>
</head>
<body>
<h1>Object Moved</h1>This document may be found
<a HREF="location_from_http_header">here</a>
</body>{the json I'm supposed to get}
along with the same valid headers. Obviously, the production is related to debug = False, my post request contains a header with Accept: application / json, although the response content type is “text / html; charset = UTF-8”.
Any idea where this could come from?