Reputation: 1542
Trying to making HTTP Post, passing two params for authentication: user,password
import requests
url = 'http://10.10.13.3:8000/api/login'
payload = {'user': 'admin', 'password': 'admin'}
response = requests.post(url,data=payload)
print response.url
print response.text
What's weird is, this code which is returning me, it's the same when I login with user/password wrong, but testing login on the website, it's working. Is this the right code to make post authentication?
Upvotes: 0
Views: 41
Reputation: 4783
you should replace data
with json
.
l
like this:
import requests
url = 'http://10.10.13.3:8000/api/login'
payload = {'user': 'admin', 'password': 'admin'}
response = requests.post(url,json=payload)
print response.url
print response.text
Upvotes: 1