Jump to content


Swarm error login using python HTTP requests

swarm python login

  • Please log in to reply
1 reply to this topic

#1 ivy

ivy

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 11 July 2017 - 08:58 AM

Hello,

I'm writing a python program to auto make pending CLs and send Swarm review, but currently get stuck in Swarm item. I could not log in successfully, even using curl or python HTTP request.
For curl:
curl -c cookie.txt -d "user=myusername&password=mypassword" https://review1716.mycompany.net
For python:
import requests
url = 'https://review1716.mycompany.net/'
values = {'user': 'myusername',
		  'password': 'mypassword'}
r = requests.post(url, data=values)
print (r.content)

Both methods returns:
{"isValid":false,"error":"Invalid username or password.","toolbar":null,"info":null,"csrf":null,"user":null}

Note that login successfully in web browser with that username and password.
My Swarm version is 'SWARM/2016.3/1472982 (2016/12/14)'
Could you please help for this case?
Thanks

#2 P4Martin

P4Martin

    Member

  • Staff
  • 19 posts
  • LocationUK

Posted 21 July 2017 - 07:12 AM

Have you tried putting the text '#review' in the changelist description before shelving them?  
Swarm triggers should automatically create reviews out of such shelved changelists.  You can even specifically add people as reviewers by tagging them with @username

https://www.perforce...ode_review.html



For calls direct to the API from CURL, i'm fairly sure you need to pass the username/password with the -u flag, ratehr than as a cookei - see the documentation for more details
https://www.perforce....endpoints.html



Also tagged with one or more of these keywords: swarm, python, login

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users