My API:
class FileView(APIView): parser_classes = (MultiPartParser,) def post(self, request): do something with request.FILES.dict().iteritems()
My requests file:
try: headers = { 'content-type': "multipart/form-data", 'authorization': "Basic ZXNlbnRpcmVcYdddddddddddddd", 'cache-control': "no-cache", } myfile = {"file": ("filexxx", open(filepath, "rb"))} response = requests.request("POST", verify=False, url=url, data=myfile, headers=headers) print(response.text) except Exception as e: print "Exception:", e
Mistake:
"Multipage form parsing error - Invalid border in multipart: None"
What is the correct way to publish a file? thanks
inquiries. version '2.10.0'
python django-rest-framework python-requests
Bae
source share