Hi so I have this method in django views to post the file to a different server. I get an HTTP 415 error complaining about the media type of the request. I have debugged the
If you look at the documentation of requests it says about the data
keyword:
data – (optional) Dictionary, bytes, or file-like object to send in the body of the Request.
Django's request
object is an instance of HttpRequest.You should try to put the necessary data in a dictionary and pass it to post()
.
Do this:
r = requests.post('http://localhost:9090/validate', data=request.POST)
You are passing a full django.http.HttpRequest
object to requests.post
, when you only need its post data.