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



  • Members
  • Pip
  • 3 posts

Posted 11 July 2017 - 08:58 AM


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?

#2 P4Martin



  • Staff
  • 21 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


For calls direct to the API from CURL, I'm fairly sure you need to pass the username/password (or username/ticket with security level 3) with the -u flag, rather than as a cookie - see the documentation for more details

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