'How to use insomnia with django?
running django locally and with firefox, i login with http://localhost:8000/admin/
and after that i can access http://localhost:8000/myCustomApi
successfully.
on insomnia every time i login with http://localhost:8000/admin/
i get {"code": "csrf", "reason": "CSRF cookie not set."}
on the response. i tried this but didn't work. is there any tutorial to what should i do?
Solution 1:[1]
- Install this plugin: https://insomnia.rest/plugins/insomnia-plugin-default-headers
- Click on your environment and then on "Manage Environments"
3. In your environment, add a new env var:
{
"DEFAULT_HEADERS": {
"X-CSRFToken": "wSYUpsSIkXxjA8wBiojsCU7YgJGYySGFWiDHNoGhEpCWGxoIyNfIvw7hr2Au1a9J"
}
}
Replace the value with one you can find in your browser.
Now, that was for sending data to forms. If you need to make a request while being loggued, click on Cookies and add a new cookie with a name sessionid and the value that you will find in your browser.
Enjoy
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Atem18 |