Search code examples
pythonpiphttpx

HTTPX DeprecationWarning: Use 'content=<...>' to upload raw bytes/text content


I installed a project that has httpx in the code and it seems that there is a method deprecated in its code. I looked for a solution but I don't find any solution for it. ( Also, I have run it before and it was working "2 weeks ago").

The error appears as follows:

Deprecation error in lib/python3.8/site-packages/httpx/_content.py:201:
DeprecationWarning: Use 'content=<...>' to upload raw bytes/text content.
warnings.warn(message, DeprecationWarning)

httpx version is httpx==0.23.1

Does anyone know how to silence or fix this warning?


Solution

  • I installed a project that has httpx

    That's a bug in the project and the only way to avoid the DeprecationWarning is to fix the project. See https://www.python-httpx.org/compatibility/#request-content :

    For uploading raw text or binary content we prefer to use a content parameter…

    Using the data=<text/byte content> will raise a deprecation warning, and is expected to be fully removed with the HTTPX 1.0 release.