Not allowed to upload this file type – REST API issue
-
Hi all, I’m having an issue and hoping someone can help.
I’m using WP REST API to try and upload a .csv file using Python. I have edited my wp-config file and functions.php file to allow csv files to be uploaded, and installed a MIME type plugin.
I can upload CSVs through the dashboard, but get this error when I try using Python:
{'code': 'rest_upload_sideload_error', 'message': 'Sorry, you are not allowed to upload this file type.', 'data': {'status': 500}}
Any ideas what could be happening here? My python is below:
user = 'myusername' password = 'xyz' url = 'https://localhost/enigma/wp-json/wp/v2/media' creds = user + ':' + password token = base64.b64encode(creds.encode()) csvname = "CSV File" csvpath = "Weekly Highlights\csv-exports\hisorical_prices.csv" csvbytes = {'file': open(csvpath, 'rb')} header = {'Authorization': 'Basic ' + token.decode('utf-8'), "Accept": "application/json", "Content-type": "text/csv", 'Content-Disposition': "attachment; filename=%s" % csvname,} post = requests.post(url, headers=header, files=csvbytes) print(post.json())
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Not allowed to upload this file type – REST API issue’ is closed to new replies.