How to login via the REST API?
https://SERVER:PORT/jts/rpt/repository/foundation?fields=foundation/contributor/(userId|name|archived)&size=999
I tried &usedId=xxxxx&password=xxxx but that was ignored - didn't even get an error.
Accepted answer
here is a little batch file using curl that will logon and get the list of projects on a server
set the user, password and host variables
set COOKIES=.\cookies.txt
set USER=
set PASSWORD=
set HOST=https://localhost:9743
curl -k -c %cookies% "%host%/jts/authenticated/identity"
curl -k -L -b %COOKIES% -c %COOKIES% -d j_username=%USER% -d j_password=%PASSWORD% "%host%/jts/authenticated/j_security_check"
curl -k -L -b %COOKIES% "%host%/ccm/oslc/workitems/catalog
Comments
Turns out curl is not necessary. I sent the following http commands without needing curl:
https://SERVER:PORT/jts/authenticated/identity
https://SERVER:PORT/jts/authenticated/j_security_check?j_username=USERID&j_password=PASSWORD
The second command returned the roles of the user, thus enabling confirmation of successful login.
Couldn't have done it without your help, though. Thanks.
correct, you don't NEED curl. bit using it demonstrates the need and solution for the session cookie returned from the 1st call.
unless you managed this is your code, the second should have failed.
if you are running with the default, Form registration.
I am hoping that cookie management is automatic and not something I'll have to worry about, at least that has been the case in the past. I'll find out when I try to create code with these calls this weekend.
I've never seen ANY code do automatic cookie mgmt..