Citrix.Image.Uploader/CCRestMethod.ps1
# # Citrix API Rest Call (Support Export/Prepare/GetJob) # Function BuildUrl([string]$serviceRoute) { $url = [System.UriBuilder] "https://api-us.cloud.com/" $url.Path = $serviceRoute return $url.Uri } Function Invoke-CCRestMethod([string]$method, [string]$serviceRoute) { $url = BuildUrl -serviceRoute $serviceRoute $moduleInfo = Get-InstalledModule 'Citrix.Image.Uploader' $parameters = @{ Headers = @{ 'Accept' = 'application/json' 'Content-Type' = 'application/json;charset=utf-8' } Method = $method UserAgent = "Citrix.Image.Uploader/$($moduleInfo.Version) Powershell/$($PSVersionTable.PSVersion)" Verbose = $VerbosePreference -eq 'Continue' } try { Log "REST $url" $false return Invoke-RestMethod $url @parameters } catch { throw "$method REST method failed: $_" } } |