0

I want to send a string through POST request like

#my data string
data='[{ "DeviceNo":"123123123","LogDate":"2018-11-18", "FileName":"X.py", "LogMessage":"Message" }]'

response = requests.post(url,files=data, timeout=20, headers={'Authorization': accessToken}) 

I dont know how to send this data. Don't know if "files=data" is a correct usage for that.

hhilal
  • 163
  • 2
  • 4
  • 17
  • Does this answer your question? [How to send a "multipart/form-data" with requests in python?](https://stackoverflow.com/questions/12385179/how-to-send-a-multipart-form-data-with-requests-in-python) – Divyesh patel Nov 18 '19 at 12:42

1 Answers1

0

following code is the solution for me. Hope it help someone (i lost so much time on this one)

data={
  "request":"{ 'action':'CreateLog', 'version':'1', 'parameters': { 'Message':'my message'}}" 
     }
response = requests.post(url,data=data, timeout=20, headers={'Authorization': accessToken})
hhilal
  • 163
  • 2
  • 4
  • 17