python post request not working with Minio server import
<p>I have a problem with POST request with Python/Django and Minio server, this is the code</p>

<pre><code>from django.http import HttpResponse
import json
from minio import Minio

minioClient = Minio('mypath:9000',
                access_key='mykey',
                secret_key='mysecret',
                secure=False)


def getMessage(request):
   if request.method == 'POST':

       data = json.loads(request.body.decode('utf-8'))

       for obj in data['files']:
           ...do some stuff....

           minioClient.fget_object(myvar, myvar2, '/tmp/processing')

    return HttpResponse(file)
</code></pre>

<p>The problem is that the request won't work if I don't remove the import at the beginning and I can't understand why. This is the error generated:</p>

<pre><code>HTTPConnectionPool(host='myhost', port=8001): 
Max retries exceeded with url: /myurl/ 
(Caused NewConnectionError
('&lt;requests.packages.urllib3.connection.HTTPConnection object at 0x7fcbeab21160&gt;: 
Failed to establish a new connection: [Errno 111] Connection refused',))
</code></pre>

<p>and this is the script that make the request is this one:</p>

<pre><code>.... some code....
try:
   r = requests.post("http://myurl:8001/mypath/", data=my_data, timeout=1)
except Exception as e:
   print(e)
</code></pre>

<p>I've already tried to increase the timeout but it's not working and of course, I've tested the Minio part in another script, the import it's generating this error only in this request script.</p>

<p>Thanks for the help</p>

<p>From docs for urllib3: </p>

<blockquote>
  <p>request(method, url, fields=None, headers=None, **urlopen_kw)Â¶ Make a
  request using urlopen() with the appropriate encoding of fields based
  on the method used.</p>
</blockquote>

<p>Maybe you could try something like this:</p>

<pre><code>r = http.request('POST', "http://myurl:8001/mypath/",
                 headers={'Content-Type': 'application/json'},
                 body=encoded_data)
</code></pre>

python django post request minio