How to send CSRF token using flutter http request

how to send CSRF token using flutter HTTP request I have a Django based project that uses django-rest-framework for API, when I send a POST request using Postman it works perfectly fine,, but when I send an HTTP.post request from my flutter application I get this response :

Forbidden 403
CSRF verification failed. Request aborted.
You are seeing this message because this HTTPS site requires a “Referer header” to be sent by your Web browser, but none was sent

In django am using function based view to receive the requests:

@api_view(['POST'])
@permission_classes([AllowAny,])
@csrf_exempt
def create_user(request):
   ......
   .....

then in the URLS :

    path("api/v1/create_user/", api.create_user, name="create_user"),

and am sending the request in flutter :

http.post(Uri(myURL),header={
    'Content-Type': 'application/x-www-form-urlencoded',
}
,body={
'my_key':'my_value',
})
Back to Top