I am trying to upload file as follows:
from requests_toolbelt import MultipartEncoder
import requests
file_details = {'upload-type': 'gallary', 'username': 'a457'}
url = "url/to/upload"
with open('path/to/file', "rb") as file:
encoder = MultipartEncoder(
fields={
"file": (
'gallary.zip',
file,
),
**file_details,
},
)
response = requests.post(url, data=encoder)
I get following error: 415 Client Error: Unsupported Media Type. The api requires json data to be submitted that is file_details should be json data. How can I fix this error?