How to specify python requests http put body?

Quoting from the docs

data – (optional) Dictionary or bytes to send in the body of the Request.

So this should work (not tested):

 filepath="yourfilename.txt"
 with open(filepath) as fh:
     mydata = fh.read()
     response = requests.put('https://api.elasticemail.com/attachments/upload',
                data=mydata,                         
                auth=('omer', 'b01ad0ce'),
                headers={'content-type':'text/plain'},
                params={'file': filepath}
                 )

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)