Guest User

Untitled

a guest
May 25th, 2021
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $InsightServerUrl = "Your Site URL Here"
  2. $Username = "Your Case Sensitive Username"
  3. $Password = "Your API KEY Here"
  4.  
  5. # Encode Creds
  6. $auth = $Username + ':' + $Password
  7. $Encoded = [System.Text.Encoding]::UTF8.GetBytes($auth)
  8. $authorizationInfo = [System.Convert]::ToBase64String($Encoded)
  9.  
  10. # Set headers with ExperimentalApi
  11. $Headers = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
  12. $Headers.Add('content-type' , 'application/json')
  13. $Headers.Add('Authorization', 'Basic ' + $authorizationInfo)
  14. $Headers.Add('X-ExperimentalApi', 'opt-in')
  15.  
  16. # Call the URI
  17. $Request = [System.UriBuilder]"$InsightServerUrl/rest/servicedeskapi/insight/workspace"
  18. $response = Invoke-RestMethod -Uri $Request.Uri -Headers $headers -Method GET
  19. $response.values.workspaceId
Add Comment
Please, Sign In to add comment