I send a POST request from IPhone to Django and get \"CSRF verification failed\", which I can\'t perfectly understand. I tried to find a good solution over the internet, but I c
Normally this boils down to setting the headers correctly. There is an answer that already details this. The relevant part you need is this:
xhr.setRequestHeader("X-CSRFToken", token)
See the linked answer for details on getting the token from the cookies, for brevity I didn't copy it from there. I don't really know the context of your code, so this method of retrieval might not directly apply. Regardless, you need to get the token somehow.
When you have the token, add a header to the NSMutableURLRequest
. Upon posting the request, the error should be gone.
[request addValue:token forHTTPHeaderField:@"X-CSRFToken"];