I'm trying to upload a file using Octoprint REST API - it seems to be possible as per the document described here, Upload file or create folder, but I can't figure it out how to do it with the Python request lib.
Currently what I'm doing is
import requests
def def Upload_File():
fle={'location':"j:/max.gcode"}
url='http://localhost:5000/api/files/{}'.format('local')
payload={'select': 'true','print': 'false' }
header={'content-type': 'multipart/form-data','X-Api-Key': 'FD550BD4DA2442BA906AD1850539D6DB' }
response = requests.post(url, files=fle,data=payload,headers=header)
print(response)
if __name__=='__main__':
Upload_File()
The response returns status is 400
My working env is:
- Windows 10 and Octoprint running on virtual environment.