Reputation: 495
In order to automate user registration in my website, I am using
>>> r = requests.post('http://www.dakshnetworks.com:8888/accounts/signup/', data=payload)
That is working well. but once the user is registered, i am directing him to another page where he has to set his workplace. So i tried to use
o= requests.post('http://www.dakshnetworks.com:8888/set/', data=payload2)
but that is not able to set the workplace of the user returning error 500
[01/Jun/2015 17:11:07] "POST /accounts/signup/ HTTP/1.1" 302 0
[01/Jun/2015 17:11:07] "GET / HTTP/1.1" 302 0
[01/Jun/2015 17:11:07] "GET /set/ HTTP/1.1" 200 26351
[01/Jun/2015 17:14:40] "POST /set HTTP/1.1" 500 75469
[01/Jun/2015 17:16:16] "POST /set/ HTTP/1.1" 500 126509
So how do i maintain the connection so that the server may know that the requests are coming from the same user.
Upvotes: 1
Views: 9671
Reputation: 1124258
Use a Session()
object to maintain cookies, so that the server knows it is still the same user:
session = requests.Session()
r = session.post('http://www.dakshnetworks.com:8888/accounts/signup/', data=payload)
o = session.post('http://www.dakshnetworks.com:8888/set/', data=payload2)
Upvotes: 2