I am sending a post request with python's requests module:
res = requests.post('https://mysite.xyz/bot/upload',
headers={'Content-type': 'text/plain'},
data=data.encode('utf8'),
verify=True)
Here is the (expected) response I get when I replace the url with https://httpbin.org/post:
{
"args": {},
"data": "test data",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Content-Length": "9",
"Content-Type": "text/plain",
"Host": "httpbin.org",
"User-Agent": "python-requests/2.20.1"
},
"json": null,
"origin": "<my IP address>, <my IP address>",
"url": "https://httpbin.org/post"
}
The server I am sending the data to uses flask. Here is the code:
@app.route('/bot/upload', methods=['POST', 'GET'])
def dataup():
data = flask.request.data
print(flask.request.content_type)
print(data)
# do stuff with it
This outputs:
None
b''
What is going wrong?