How to post a django request to external server

后端 未结 2 654
遥遥无期
遥遥无期 2021-01-14 19:40

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

2条回答
  •  既然无缘
    2021-01-14 20:04

    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().

提交回复
热议问题