0

I'm trying to send an email and a password through a POST, but the way I'm doing it in the code below it's not working. How could I do this correctly?

import requests
inf = '{"user_email": "celes.....bosa@gmail.com", "user_password": "xxxxxxxxx"}'
z = requests.post('https://www.iped.com.br/api/user/login', data=inf)
print(z)
print(z.json())
  • try `inf = {"user_email": "celes.....bosa@gmail.com", "user_password": "xxxxxxxxx"} requests.post('https://www.iped.com.br/api/user/login', json=inf)` – Shanavas M Nov 18 '21 at 17:39

1 Answers1

0

You need to let inf as a dict in order to send it using data= parameter.

Check the help for requests.post:

post(url, data=None, json=None, **kwargs)
Sends a POST request.

:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
    object to send in the body of the :class:`Request`.
:param json: (optional) json data to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:return: :class:`Response <Response>` object
:rtype: requests.Response

Make sure to check also this: How to POST JSON data with Python Requests?

Dan Constantinescu
  • 1,426
  • 1
  • 7
  • 11