I am trying to consume data from a callback API that sends the POST request in this format:
[
{
"key1": "asd",
"key2": "123"
}
]
However my API currently only works when it is sent like this:
{
"key1": "asd",
"key2": "123"
}
serializers.py:
class RawIncomingDataSerializer(serializers.ModelSerializer):
class Meta:
model = RawIncomingData
fields = '__all__'
views.py:
class RawIncomingDataViewSet(viewsets.ModelViewSet):
queryset = RawIncomingData.objects.all()
serializer_class = RawIncomingDataSerializer
There will only ever be one object in the post data, so I am looking for a simple work around without having to rewrite my serializer to interpret multiple objects in one post request.
update
andretrieve
right? In this case, with this approach there would be a need to also check whether the action wascreate
or the method waspost
before usingmany=True
– Ericson