Skip to main content
Hi all, I have been struggling to implement an automatic script to integrate with the REST API of Sysaid. After a lot of research, I was able to come up with a script that can acheive the following: - Login to Sysaid and get the "Web Session Token" - With the web session token, access the REST API as documented by Sysaid Here it goes: Function LoginToSysaid: Takes in a username ($username) and a password ($password) and returns a Web Session code Function GetTicketInformation: Give you the JSON information of a ticket (Whole ticket) with a given $ticketID and $sessionToken Function UpdateValue: Updates the value of a key ($updateKey) in Sysaid (Could be title, description, notes, see Sysaid Documentation on the REST API) with a new value ($newValue), a ticket ID ($ticketID) and a $sessionToken You must use the LoginToSysaid first to get the session token, then you can use the other functions to do whatever you want :) $SysaidURL = 'YourSysaidURLWithHttpAndPortNumber' Function LoginToSysaid { #This Function returns a connection session token to be used by further actions Param ([string]$username,[string]$password) $Request = invoke-webrequest -uri "$SysaidURL/Login.jsp" -SessionVariable RSession $Form = $Request.Forms[0] $Form.Fields["userName"]=$username $Form.Fields["password"]=$password $Request = Invoke-WebRequest -Uri ("$SysaidURL/Login.jsp" + $Form.Action) -WebSession $RSession -Method POST -Body $Form.Fields [Microsoft.PowerShell.Commands.WebRequestSession]$RSession = $RSession return $RSession } Function GetTicketInformation { #This Function returns a connection session token Param ([string]$ticketID,[Microsoft.PowerShell.Commands.WebRequestSession]$sessionToken) $apiUrl = 'api/v1/sr/' $finalURL = $SysaidURL + $apiUrl + $ticketID $result = Invoke-RestMethod -uri $finalURL -WebSession $sessionToken return $result } Function UpdateValue { #This functions updates a value of a ticket Param ([string]$ticketID,[string]$updateKey,[Microsoft.PowerShell.Commands.WebRequestSession]$sessionToken,[string]$newValue) $apiUrl = 'api/v1/sr/' $finalUrl = $SysaidURL + $apiUrl + $ticketID $jsonApiCall = '{"id":"' + $ticketID + '","info":[{"key":"' + $updateKey + '",value":"' + $ccValue + '"}]}' $result = Invoke-RestMethod -uri $finalUrl -WebSession $sessionToken -Method Put -ContentType 'application/json' -Body $jsonApiCall return $result } Let me know if this is useful to you :)
I would love it if someone could post a basic SOAP version of this. I'm just trying to pull ticket info and the important fields to a internal REST API.