'Django XML file upload API not getting called and [error]: method not allowed

I am working on Django project that will upload XML file via rest API and i am facing issue and not sure what it is !

i am sharing my Codes that i have written for Different Modules for [API]

URL.py

path('xml-file/', xmlfileview.as_view(), name='xml-file')

Serializers.py

class xmlfileSerializer(serializers.ModelSerializer):
file = serializers.FileField()
class Meta:
    model = xmlColumns
    fields = ['inputfile']

Views.py

class xmlfileview(generics.CreateAPIView):
serializer_class = xmlfileSerializer
# parser_classes = (FileUploadParser,)

def post(self, request, *args, **kwargs):
    token = request.META.get('HTTP_AUTHORIZATION')
    try:  #
        payload = jwt.decode(token,
                             settings.SECRET_KEY)  # payload is a dictionary to decode the token to get the user id
        user = User.objects.get(id=payload['user_id'])  # user is a function to get the user model

        if user.is_verified:
            print(user)
            # serializer = self.get_serializer(data=request.data)
            # serializer.is_valid(raise_exception=True)
            # serializer.save()
            # file = serializer.validated_data['file']
            # print(file)
            file_obj = request.data['file']
            df = pd.read_xml(file_obj)
            for col in df.columns:
                print(col)
            # print(df)
            return Response({'msg': 'file sent'}, status=status.HTTP_400_BAD_REQUEST)

    except jwt.ExpiredSignatureError as identifier:
        return Response({'error': 'Activation Expired'}, status=status.HTTP_400_BAD_REQUEST)
    except jwt.exceptions.DecodeError as identifier:
        return Response({'error': 'Invalid token'}, status=status.HTTP_400_BAD_REQUEST)

Models.py

class xmlColumns(models.Model):
    ipfile = models.FileField()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source