Login
post
/rest/{versionId}/admin/login
Use this (POST) method to authenticate and establish as user session on the SDM server. A user must establish a valid authenticated session before other method calls can be used. The response to a successful authentication returns a valid time-limited session cookie that needs to be returned with all subsequent REST requests to establish the user has an authenticated session in progress.
Request
Supported Media Types
- application/xml
- application/json
Path Parameters
Header Parameters
Response
Supported Media Types
- application/xml
- application/json
200 Response
successful operation
400 Response
The user input is invalid.
401 Response
The user ID or password is invalid.
404 Response
The REST API version of your input request cannot be found.
Examples
Example of Accessing the API with cURL
The following example shows how to login by submitting a POST request on the REST resource using cURL. For more information about cURL, see Use cURL.
curl -X POST \
-c sessionid.txt \
-d@request.xml \
--header "Accept: application/xml" \
--header "Content-Type: application/xml" \
"https://example.com:8443/rest/v1.3/admin/login"
The following shows an example of the contents of the request.xml
file sent as the request body.
<?xml version="1.0" encoding="UTF-8"?>
<session>
<userName>admin</userName>
<password>password</password>
</session>
Example of Accessing the API with Python
The following example shows how to login by submitting a POST request on the REST resource using Python.
import requests
from lxml import etree
url = "http://example.com:8080/rest/v1.3/admin/login"
headers = { "Accept":"application/xml", "Content-Type":"application/xml" }
data = etree.tostring(etree.parse("request.xml"))
resp = requests.post(url, headers=headers, data=data)
# extract the cookie from the response
tree = etree.fromstring(resp.content)
cookie = tree.xpath('//sessionId')[0].text
# add the cookie to the headers dictionary for subsequent requests
headers['Cookie'] = cookie
Example of the Response Headers
The following shows an example of the response headers.
HTTP/1.1 200 OK
Date: Thu, 25 Apr 2019 09:46:57 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
vary: Origin,Accept-Encoding
Set-Cookie: JSESSIONID=37366B7ECFF47D540C87705CF7584AD9.tomcat1; Path=/rest; HttpOnly
Content-Length: 304
Content-Type: application/xml
Example of the Response Body
The following example shows the contents of the response body in XML format.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<session>
<idleTimeout>0</idleTimeout>
<serverInfo>NNC82</serverInfo>
<sessionId>37366B7ECFF47D540C87705CF7584AD9.tomcat1</sessionId>
<userGroup>administrators</userGroup>
<userName>admin</userName>
<validUntil>valid until logout</validUntil>
</session>