I am trying to update an image using the Wordpress rest api in Python. I get the status code 200 but the image does not update. I have not found any solution online other than replacing http with https.
def restImgUL(imgPath, imgId=''):
url='https://example.com/wp-json/wp/v2/media/' + imgId
data = open(imgPath, 'rb').read()
fileName = os.path.basename(imgPath)
user = ""
password = ""
credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
res = requests.post(url=url,
data=data,
headers={'Authorization': 'Basic ' + token.decode('utf-8'), 'Content-Type': 'image/jpg','Content-Disposition' : 'attachment; filename=%s'% fileName, })
print(res.status_code)
print(res.text)