The following article describes a complete script one can leverage to test Service Desk REST access via Powershell. With all values entered correctly, based on an existing, operational SDM installation with REST web services deployed, it will perform a login and obtain a list of priority table content.
Release 17.3 or higher
CA Service Desk Manager
This document assumes you have some knowledge of Windows PowerShell and the CA Service Desk Manager REST Web Services API.
Broadcom Support provides this document as an example with no guarantees. Broadcom Support will not assist you with PowerShell. However, we can assist with any queries related to the Service Desk REST based Web Services API.
# BEGIN SCRIPT
# This will setup login credentials
$User = "<USERID>"
$PWord = ConvertTo-SecureString -String "<PASSWORD>" -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
# This is the base URI
$URI_base = "http://<SDM-SERVER>:8050/caisd-rest/"
# This is the content needed for rest access
$URI_rest_access = $URI_base + "rest_access"
$Body_rest_access = "<rest_access/>"
# Invocation to establish login to REST Web Access
$result_rest_access = Invoke-RestMethod -Method 'POST' -Uri $URI_rest_access -Credential $Cred -ContentType "application/xml" -Body $Body_rest_access
"REST Access Key: " + $result_rest_access.rest_access.access_key
# Establish headers needed to obtain request data
$Getheaders.clear
$Getheaders = @{}
$Getheaders.Add("X-AccessKey", $result_rest_access.rest_access.access_key)
# This is the URI needed for obtaining pri (Priority table) data
$URI_pri = $URI_base + "pri"
# Invocation to acquire Priority Table content
$result_pri = Invoke-RestMethod -Method 'GET' -Uri $URI_pri -ContentType "application/xml" -Headers $Getheaders
# display Priority result set
$result_pri.collection_pri.pri
# Invocation to DELETE REST Web Access
$URI_rest_access_DEL = $URI_rest_access+"/"+$result_rest_access.rest_access.id
$result_rest_access_DEL = Invoke-RestMethod -Method 'DELETE' -Uri $URI_rest_access_DEL -ContentType "application/xml" -Headers $Getheaders
# END SCRIPT
Replace all highlighted sections with values that pertain to your environment
PS C:\PSTest> .\test-sdm-rest.ps1
Rest Access Key: 1015563409
id REL_ATTR COMMON_NAME link
-- -------- ----------- ----
500 1 5 link
501 2 4 link
502 3 3 link
503 4 2 link
504 5 1 link
505 0 None link
If you have debug logging enabled in SDM per KB Article 120004, you can search for the above access key to review activity. Debug content is written to the NX_ROOT\log\jrest.log
03/26 20:05:01.892 [http-nio-8050-exec-2] DEBUG DAL_JDBC 132 Statement.executeQuery (0ms): SELECT contact FROM rest_access WHERE access_key = 1015563409
03/26 20:05:01.892 [http-nio-8050-exec-2] DEBUG RoleHandler 84 Calling change_rest_role() for sessionId (1015563409) cntId (U'<UUID DATA>') to roleId -1
03/26 20:05:01.892 [http-nio-8050-exec-2] DEBUG LoggingConnectionFactory 57 Creating DAL connection. SessionContext(sessionId=1015563409, userToken=TESTUSER, contextTenantId=null, filterQuery=false, filterTenantUUIDList=null, parentTenantUUIDList=null)
03/26 20:05:01.892 [http-nio-8050-exec-2] DEBUG priService -1 -----> GET/getObjects() for collection of resources (pri)
03/26 20:05:01.892 [http-nio-8050-exec-2] DEBUG SDMCRUDServiceImpl 1712 GetObjects URI (http://<SDM-SERVER>:8050/caisd-rest/pri)
03/26 20:05:01.908 [http-nio-8050-exec-2] DEBUG DalUtilities 897 getObjectsCountQuery return: SELECT COUNT(*) FROM pri
The above is only a sample script that demonstrates basic REST access via Powershell and is provided "as is". Broadcom Support does not warrant the above script for functionality and bears no responsibility for its usage in any environment. Please take all necessary precautions before running the above script (test in a non-prod environment).
Broadcom Support is also not permitted to advise or collaborate on the above script, including any further modifications or changes.
A counterpart document for SOAP Web Services and Powershell testing is available in KB Article 49239.