Send multipart/form-data string with POST requests, python

hhilal

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

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})

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

send data to create incident to Dynamics 365 with Python Requests post() Method

Send http post request with unicoded data using python requests

How to send a post request with data using python requests module?

Python requests send certificate as string

what is the default encoding when python Requests post data is string type?

Handling post data with requests in python

Python: Issue with POST data in Requests

Error to post the data in python requests

How to send a "string array" as HTTP post data from Python?

Why can't I send `None` as data in a POST request using Python's `requests` library?

Send "\r\n" symbols in python requests data

python requests How to send data to a website

Using python requests to POST data with file

How to POST JSON data with Python Requests?

POST request via requests (python) not returning data

Python requests http post data with cookies

How to stream POST data into Python requests?

Python requests post json raw data

Using Python Requests to POST data to REST API

Post data (dictionary list) with python requests

How to send an array of String as the post data to a webserver?

Python + requests, How I send username & password in POST?

How to send cookies in a post request with the Python Requests library?

How to send cookies in a post request with the Python Requests library?

Python / Requests - Can't send POST properly, despite it is working in Postman

python servers send specific info from post requests

How to send '-X POST' using 'requests' library in Python?

How to send raw data in a POST request Python

Post a string as multipart/form-data using requests