Search code examples
pythontornado

Send form data from Tornado HTTPClient


How can I use the fetch method to send multipart form data in a POST request? I don't see this mentioned in the documentation anywhere.

I tried this, but the arguments on the server (HTTPServerRequest.arguments) were empty:

client.fetch(
    '/foo/bar',
    headers={'Content-Type': 'form-data'},
    body=urllib.parse.urlencode({'a': 1, 'b': 2})
)

Solution

  • Have a read here: on another StackOverflow question answered

    I believe any answer will more or less be similar to the link I've pointed out. The Http method you use should not matter at this point. Most of the issue is about constructing the multipart request.