How to properly use requests.post in Python for API calls? or Getting errors with requests.post in Py

18 Replies, 1032 Views

Bro, I feel you. Had the same issue last week. Turns out my `headers` were missing `'Content-Type': 'application/json'`.

For retries, this snippet saved me:

```python
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry

session = requests.Session()
retries = Retry(total=3, backoff_factor=1)
session.mount('http://', HTTPAdapter(max_retries=retries))
```

Give it a shot!

Messages In This Thread



Users browsing this thread: 1 Guest(s)