🌐
PyPI
pypi.org › project › urllib3
urllib3
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
urllib3
urllib3.readthedocs.io › en › stable › user-guide.html
User Guide - urllib3 2.7.0 documentation
urllib3 can be installed with pip · $ python -m pip install urllib3 · First things first, import the urllib3 module: import urllib3 · You’ll need a PoolManager instance to make requests.
🌐
GitHub
github.com › urllib3 › urllib3
GitHub - urllib3/urllib3: urllib3 is a user-friendly HTTP client library for Python · GitHub
urllib3 is a user-friendly HTTP client library for Python - urllib3/urllib3
Starred by 4K users
Forked by 1.4K users
Languages   Python
🌐
ZetCode
zetcode.com › python › urllib3
Python urllib3 - accessing web resources via HTTP
January 29, 2024 - headers = urllib3.make_headers(keep_alive=True, user_agent='Python program')
🌐
ProgramCreek
programcreek.com › python › example › 72024 › urllib3
Python Examples of urllib3
Please" "migrate away as soon as possible.") if "INSTANA_API_TOKEN" in os.environ: self.api_token = os.environ["INSTANA_API_TOKEN"] if "INSTANA_BASE_URL" in os.environ: self.base_url = os.environ["INSTANA_BASE_URL"] if self.base_url is None or self.api_token is None: log.warn("APIClient: API token or Base URL not set. No-op mode") else: self.api_key = "apiToken %s" % self.api_token self.headers = {'Authorization': self.api_key, 'User-Agent': 'instana-python-sensor v' + package_version()} self.http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())
🌐
Snyk
snyk.io › advisor › urllib3 › urllib3 code examples
Top 5 urllib3 Code Examples | Snyk
import sdk_utils log = logging.getLogger(__name__) DEFAULT_TIMEOUT_SECONDS = 30 * 60 SSH_USERNAME = os.environ.get("DCOS_SSH_USERNAME", "core") SSH_KEY_FILE = os.environ.get("DCOS_SSH_KEY_FILE", "") # Silence this warning. We expect certs to be self-signed: # /usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py:857: # InsecureRequestWarning: Unverified HTTPS request is being made.
🌐
Stack Abuse
stackabuse.com › guide-to-sending-http-requests-in-python-with-urllib3
Guide to Sending HTTP Requests in Python with urllib3
May 4, 2023 - Finally, let's take a look at how to send different request types via urllib3, and how to interpret the data that's returned. An HTTP GET request is used when a client requests to retrieve data from a server, without modifying it in any way, shape or form. To send an HTTP GET request in Python, we use the request() method of the PoolManager instance, passing in the appropriate HTTP Verb and the resource we're sending a request for:
🌐
urllib3
urllib3.readthedocs.io
urllib3 2.7.0 documentation
urllib3 is a powerful, user-friendly HTTP client for Python. Much of the Python ecosystem already uses urllib3 and you should too. urllib3 brings many critical features that are missing from the Py...
🌐
Python Programming
pythonprogramming.net › urllib-tutorial-python-3
Python urllib tutorial for Accessing the Internet
This is how Google Analytics knows what browser you are using, for example. Within the header, there is a value called user-agent, which defines the browser that is accessing the website's server. If you are using the default python user-agent with urllib, then you are announcing yourself as Python-urllib/3.4, if your Python version is 3.4.
Find elsewhere
🌐
w3resource
w3resource.com › python-exercises › urllib3 › index.php
Python urllib3 - Exercises, Practice, Solutions
September 3, 2025 - Explore urllib3 exercises and solutions in Python, covering HTTP requests, custom headers, timeouts, redirects, SSL/TLS verification, and more.
🌐
urllib3
urllib3.readthedocs.io › en › latest › user-guide.html
User Guide - urllib3 2.6.4.dev31 documentation
urllib3 can be installed with pip · $ python -m pip install urllib3 · First things first, import the urllib3 module: import urllib3 · You’ll need a PoolManager instance to make requests.
🌐
WebScraping.AI
webscraping.ai › faq › urllib3 › how-do-i-handle-http-get-requests-using-urllib3
How do I handle HTTP GET requests using urllib3? | WebScraping.AI
import urllib3 # Create PoolManager with custom settings http = urllib3.PoolManager( num_pools=10, # Number of connection pools maxsize=10, # Max connections per pool retries=3, # Retry failed requests timeout=30.0 # Request timeout in seconds )
🌐
GitHub
github.com › urllib3 › urllib3 › blob › main › docs › user-guide.rst
urllib3/docs/user-guide.rst at main · urllib3/urllib3
urllib3 can be installed with pip · $ python -m pip install urllib3 · First things first, import the urllib3 module: import urllib3 · You'll need a :class:`~poolmanager.PoolManager` instance to make requests.
Author   urllib3
🌐
Python
docs.python.org › 3 › library › urllib.html
urllib — URL handling modules
Source code: Lib/urllib/ urllib is a package that collects several modules for working with URLs: urllib.request for opening and reading URLs, urllib.error containing the exceptions raised by urlli...
🌐
w3resource
w3resource.com › python-exercises › urllib3 › python-urllib3-exercise-1.php
Python HTTP GET Request to Public API example
September 3, 2025 - Write a Python program that performs a simple HTTP GET request to a public API (e.g., JSONPlaceholder) and prints the response. ... # Import the urllib3 library import urllib3 # Create a PoolManager instance to manage HTTP connections http = ...
🌐
urllib3
urllib3.readthedocs.io › en › latest › advanced-usage.html
Advanced Usage - urllib3 2.6.4.dev31 documentation
$ python -m pip install urllib3[zstd] ... Zstandard support in urllib3 requires using v0.18.0 or later of the zstandard package. If the version installed is less than v0.18.0 then Zstandard support won’t be enabled. Here’s an example using zstd encoding via the Accept-Encoding header:
Top answer
1 of 3
46

Since you're trying to pass in a JSON request, you'll need to encode the body as JSON and pass it in with the body field.

For your example, you want to do something like:

import json
encoded_body = json.dumps({
        "description": "Tenaris",
        "ticker": "TS.BA",
        "industry": "Metalúrgica",
        "currency": "ARS",
    })

http = urllib3.PoolManager()

r = http.request('POST', 'http://localhost:8080/assets',
                 headers={'Content-Type': 'application/json'},
                 body=encoded_body)

print r.read() # Do something with the response?

Edit: My original answer was wrong. Updated it to encode the JSON. Also, related question: How do I pass raw POST data into urllib3?

2 of 3
3

I ran into this issue when making a call to Gitlab CI. Since the above did not work for me (gave me some kind of error about not being able to concatenate bytes to a string), and because the arguments I was attempting to pass were nested, I thought I would post what ended up working for me:

API_ENDPOINT = "https://gitlab.com/api/v4/projects/{}/pipeline".format(GITLAB_PROJECT_ID)

API_TOKEN = "SomeToken"

data = {
    "ref": ref,
    "variables": [
        {
            "key": "ENVIRONMENT",
            "value": some_env
        },
        {   "key": "S3BUCKET",
            "value": some_bucket
        },
    ]
}

req_headers = {
    'Content-Type': 'application/json',
    'PRIVATE-TOKEN': API_TOKEN,
}

http = urllib3.PoolManager()

encoded_data = json.dumps(data).encode('utf-8')

r = http.request('POST', API_ENDPOINT,
             headers=req_headers,
             body=encoded_data)

resp_body = r.data.decode('utf-8')
resp_dict = json.loads(r.data.decode('utf-8'))

logger.info('Response Code: {}'.format(r.status))
logger.info('Response Body: {}'.format(resp_body))

if 'message' in resp_body:
    logfile_msg = 'Failed Gitlab Response-- {} {message}'.format(r.status, **resp_dict)
🌐
urllib3
urllib3.readthedocs.io › en › stable › advanced-usage.html
Advanced Usage - urllib3 2.7.0 documentation
$ python -m pip install urllib3[zstd] ... Zstandard support in urllib3 requires using v0.18.0 or later of the zstandard package. If the version installed is less than v0.18.0 then Zstandard support won’t be enabled. Here’s an example using zstd encoding via the Accept-Encoding header: