I am trying to upload an image file using swagger it throws
{ "detail": "CSRF Failed: CSRF token missing or incorrect." }
. It is important to mention that i'm using django-rest-swagger version 0.3.0 and django version 1.7.
YAML for uploading a picture looks like:
parameters: - name: image in: formData required: true type: file - name: caption required: true type: string
I don't want to use @csrf_exempt. I tried to pass a header into this but that didn't work. header was something like:
- name: X-CSRF-Token description: csrftoken to be passed in header in: header required: true type: string
any help will be appreciated.
I had the same issue, if you're up to date with Django, it's just a misnamed header.
Use 'X-CSRFToken' instead of 'X-CSRF-Token', that worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With