Creating a session ID¶
You can use the REST API to create a session and obtain the session ID.
Method and URI¶
To create a session, use a POST method and a URI:
POST https://{hostname|IPv4}/api/endeavour/session
This is the only request type of the REST API that does not require a session ID, but does require a username and a password.
Parameters¶
None.
Example: Create a new session¶
Assume that you want to create a session for the following IBM Spectrum Protect Plus application and the following user:
IBM Spectrum Protect Plus
IPv4 address: 10.0.0.100
SSL authentication: Disable
User
User name: Sarah
Password:
MyPassw0rd!
A Python snippet that is similar to the following example can be used to request a new session ID from IBM Spectrum Protect Plus. As you can see, the headers
section does not include the X-Endeavour-Sessionid
key-value pair. The script results in a lengthy JSON object with the new session ID.
import json
import requests
spp_ipv4 = '10.0.0.100'
spp_username = 'Sarah'
spp_password = 'MyPassw0rd!'
spp_verify = False # Disable SSL.
# Ignore warning for SSL not being used
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
_requests = requests.post('https://' + spp_ipv4 + '/api/endeavour/session',
auth=(spp_username, spp_password),
headers={
'Accept': 'application/json',
'Content-type': 'application/json'
},
params="", data="", verify=spp_verify)
_response = json.loads(_requests.text) # Convert to JSON

Figure 2 The same action can be taken in the IBM Spectrum Protect Plus web user interface: Open IBM Spectrum Protect Plus, enter the username and password, and click Sign in. If the authentication is successful, your browser receives a session ID that is associated with this user account.¶
You will get the session information associated with this user.
{
"sessionid": "43b3b1b2cc434f4eb1b9df8c99e7866f",
"user": {
"links": {...},
"name": "Sarah",
"type": "NATIVE_USER",
"typeDisplayName": "Native User",
"tenantId": 1000,
"loginCount": 24,
"lastLogin": 1573480672249,
"failedLogin": 0,
"lastFailedLogin": 1572752667593,
"lastPasswordUpdate": 1564686262606,
"passwordAge": 0,
"passwordExpiresAt": 0,
"passwordExpired": false,
"accountDisabled": false,
"accountLocked": false,
"rbacPath": "user:0/user:1000",
"permissions": [
{
"resourcePool": {
"links": {...},
"name": "All Resources",
"description": "Includes every resource in the system. ",
"total": 0,
"resources": [
{
"metadata": {},
"include": true,
"path": "root:0",
"displayName": "Unknown"
}
],
"rbacPath": "resourcepool:0/resourcepool:1001",
"id": "1001"
},
"roles": [
{
"links": {...},
"name": "SUPERUSER",
"type": "BUILTIN",
"description": null,
"displayName": "SUPERUSER",
"rbacPath": "role:0/role:1000",
"id": "1000",
"virtualresources": []
}
],
"permissionIds": [],
"roleIds": []
}
],
"personas": [],
"metadata": {
"quickStartAtLogin": true,
"jobStatusPeriod": 12,
"whatsNewBanner": "10.1.5",
"jobLogTypes": [
"INFO",
"WARN",
"ERROR",
"SUMMARY"
],
"jobLogTypes_JobsOps": [
"INFO",
"WARN",
"ERROR",
"SUMMARY"
],
"jobHistoryStatusPeriod": 12,
"initialLogin": 1567668700334,
"feedbackLastShown": 1570438820557
},
"id": "1000"
},
"demo": false,
"tenantAdmin": true,
"userGroups": [],
"timeZone": "UTC",
"useServerTime": false,
"passwordExpired": false,
"usernameExpired": false,
"accountDisabled": false,
"passwordAge": 0,
"passwordExpiresAt": 0
}
Normally, you want to get only the session ID, which is represented by the value of sessionid
:
_session_id = _response['sessionid']
print(_session_id)
43b3b1b2cc434f4eb1b9df8c99e7866f
Use this session ID value in the header of future requests:
_header={
'X-Endeavour-Sessionid': _session_id,
'Accept': 'application/json',
'Content-type': 'application/json'
}