and if a problem exists go to your Django app settings.py file and disable session as follow
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
#'rest_framework.authentication.SessionAuthentication', # disable this
),}
some people may suggest disabling CSRF in middleware(this is not recommended)
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', ]
this same in stackoverflow you can check foollowing
CodePudding user response:
It ended up being that in my urls.py the route ended with a "/" that I forgot to add to the url in postman. I tried the opposite and the same error was thrown.