Request/Close-SDPRequest.ps1
Function Close-SDPRequest { <# .SYNOPSIS Close request .PARAMETER RequestId Request id .PARAMETER InputData Input data as hashtable or JSON string .EXAMPLE $InputData = @{ "request"= @{ "closure_info"= @{ "requester_ack_resolution"= $true "requester_ack_comments"= "Mail fetching is up and running now" "closure_comments"= "Reset the pasword solved the issue" "closure_code"= @{ "name"= "success" } } } } $Request = Close-SDPRequest -RequestId 54321 -InputData $InputData .NOTES Author: Michal Gajda .LINK https://ui.servicedeskplus.com/APIDocs3/index.html#close-request #> [CmdletBinding( SupportsShouldProcess=$True, ConfirmImpact="Low" )] param ( [String]$UriSDP, [String]$ApiKey, [Parameter(Mandatory=$true, ValueFromPipeline)] [Int]$RequestId, [Parameter(Mandatory=$true)] $InputData ) Begin { #Create headers if(!$MyInvocation.BoundParameters.ContainsKey("UriSDP")) { $UriSDP = $Global:UriSDP } if(!$MyInvocation.BoundParameters.ContainsKey("ApiKey")) { $ApiKey = $Global:ApiKey } } Process { #Get by ID $InvokeParams = @{ UriSDP = $UriSDP ApiKey = $ApiKey Method = "PUT" EntityUri = "/api/v3/requests/$RequestId/close" InputData = $InputData } #Send request If ($PSCmdlet.ShouldProcess($RequestId,"Close request by id")) { $Result = Invoke-SDPAPIEntity @InvokeParams $Results = $Result.response_status } #Return result if($MyInvocation.BoundParameters.ContainsKey("Debug")) { Return $Result } else { Return $Results } } End{} } |