# basic information # The access-token needs to be a System Access Token with the appropriate access # For more information see https://MyLoginEnterpriseAppliance/external-notifications/public-api [string]$accessToken = "U49-UKj5rtzP5cuL-PcsQsAQxtbGhwVT3OZesdLlUAE" [string]$baseUrl = 'MyLoginEnterpriseAppliance/publicApi' # Test id $testId = '3a9f24a1-232f-4849-8a37-56117ba82734' # Start-request data $requestObject = @{ # Comment 'comment' = '...' } # if something goes wrong we stop processing this script $ErrorActionPreference = 'Stop' # this is only required for older version of PowerShell/.NET [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls11 # WARNING: ignoring SSL/TLS certificate errors is a security risk [System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true; } # set the content-type and add the authorization http header with our access token $requestHeaders = @{ 'Content-Type' = 'application/json' 'Authorization' = "Bearer $accessToken" } $requestBody = ConvertTo-Json -InputObject $requestObject try { $response = Invoke-RestMethod -Method Put -Uri "${baseUrl}/v4/tests/${testId}/start" -Headers $requestHeaders -Body $requestBody Write-Host -Object 'Success' } catch { [int]$statusCode = $_.Exception.Response.StatusCode; switch ($statusCode) { 404 { Write-Host -Object 'Not Found' } 409 { Write-Host -Object 'Conflict' } 400 { Write-Host -Object 'Bad Request' } 401 { Write-Host -Object 'Unauthorized' } default { throw } } }