This is how I form the headers:
headers = {
‘Authorization’: f"Bearer {jwt}",
}
I know am getting the jwt successfully. I also can verify because I also wrote code to publish a new “Product” object and I was able to create and object. The trouble is with upload.
Let me share my code:
subprocess.run(["curl", "-H", f"'Authorization: Bearer {jwt}'", '-X', 'POST', 'http://<my strapi server id address>:1337/api/upload', '-H', "'content-type: multipart/form-data;'", '-F', "'file=/path/to/my/file/@Afilename.stl'"], shell=True, check=True)
here is another way I tried it:
url = f"{strapi_server_url}/api/upload"
headers = { 'Authorization': f"Bearer {jwt}"}
filename = "filename.stl"
file=open(os.getcwd() + f'\\{filename}', 'rb')
payload={'submit': "Submit"}
response = requests.post(url, files={'file': (filename, file )}, data=payload, headers=headers)