0

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?

Artemis
  • 2,553
  • 7
  • 21
  • 36
  • @Jon ah my bad I saw that but didn't think it would work because the mime type was None. – Artemis Oct 19 '19 at 13:29
  • @Jon actually tested and it's still not working... with `flask.request.form` I get `ImmutableMultiDict([])` as output. `flask.request.get_data()` is the same. – Artemis Oct 19 '19 at 13:48
  • Can you [edit] to reflect the additional things you've tried and results? – Jon Clements Oct 19 '19 at 14:19

0 Answers0