Matteo Possamai
Matteo Possamai

Reputation: 564

"detail": "CSRF Failed: CSRF token missing."

I was trying to test my API in DJango, but while trying to use a POST request to create a user, the following error shows up:

"detail": "CSRF Failed: CSRF token missing."

What should I do? Can I remove this? Or how should I pass the CSRF also in testing and in production? In theory, I put the false in CSRF_COOKIE_SECURE, so, I don't know what to do.

Upvotes: -1

Views: 403

Answers (1)

Tanveer
Tanveer

Reputation: 1205

you have to add CSRF token to the request(and postman):

data: { csrfmiddlewaretoken: csrf_token, "username": "thesamething", "email": "thesamething", "password": "thesamething" }

Upvotes: 2

Related Questions