Home Analyst Portal

Using Authentication Token through PowerShell

Mike_RistonMike_Riston Customer IT Monkey ✭
edited February 2017 in Analyst Portal
Hi all, I'm trying to get my portal to be available to me from within PowerShell. I've gotten so far as to get an authentication token from the system, but am stumbling on how to actually get it to allow me to pass it through.

Following the API documentation, I'm passing my token value in through the headers, but I continue to either get an unauthorized message, or an invalid header structure.

Here is how I'm gathering my token, but past this, I'm just stumbling on getting data out. 

$Headers = @{}
$Headers = $Headers | ConvertTo-Json
$URI = "$URL/api/V3/Authorization/GetToken"
Invoke-RestMethod -Uri $URI -Body $Headers -Method Post

(Apologies if this is simple - but all the more reason to help, right?!)


  • Conner_WoodConner_Wood Customer Advanced IT Monkey ✭✭✭
    Are you required to enter credentials?  If you can use default credentials then I recommend looking at the following thread: Has anyone had any luck getting the UpdateWatchlistByWorkItemId API to work?

    If required, then I believe this example is what you're looking for from Cireson KA#1199
    The Cireson Portal API endpoints can be utlized using PowerShell.  The Cireson Portal API documentation can be found here:  https://support.cireson.com/Help
    The following is an example of how to create a new announcement using the Cireson Portal API and PowerShell.
    Just modify the script to use your own environment URL and credentials.
    #enter your portal URL here
    $site = "http://localhost"
    $credentials = @{
    $jsonCredentials = $credentials | ConvertTo-Json
    #first retrieve your access token
    $url = $site+"/api/V3/Authorization/GetToken"
    $apiKey = try { Invoke-RestMethod $url -Method POST -Body $jsonCredentials -ContentType 'application/json' } catch { $_.Exception.Response }
    $newId = [guid]::NewGuid()
    $body = @{
       "Id" = $newId 
       "Title" = "Test Announcement Powershell"
           "Priority"= @{"Id"="64096F7F-F8E0-491C-A7FE-94FEDDED4715"}  #enter the enumeration Id
       "Body" = "Text Update"
           "AccessGroupId"= @{"Id"="532C1C69-F1CD-1FA1-9FCF-6281654E7E02"}  #enter the group Id
       "StartDate" = "2015-07-08T05:00:00.116Z"
       "EndDate" = "2015-07-08T12:00:00.116Z"
       "Locale" = "ENU"
    $authVal = "Token " + $apiKey
    $jsonBody = $body | ConvertTo-Json
    $url = $site +"/api/V3/Announcement/UpdateAnnouncement"
    $response = try { Invoke-RestMethod $url -Method POST -Body $jsonBody -ContentType 'application/json' -Headers @{"AUTHORIZATION"=$authVal} } catch { $_.Exception.Response }

  • Karen_Bruster1Karen_Bruster1 Member IT Monkey ✭
    @Conner_Wood the enumeration ID and the group id you have in the script are they default items?
  • Conner_WoodConner_Wood Customer Advanced IT Monkey ✭✭✭
    @Karen_Bruster1 I've never used Announcements due to the work environment, however I believe that no those are not default items.  These parameters were copied from UpdateAnnouncement Response Format Sample and none of the System.Announcement.PriorityEnum Enumerations match when viewing through SCSM Entity Explorer:
    • System.Announcement.PriorityEnum.Low == 9cb0e9c2-4012-c30b-1e91-5e1272083d7b
    • System.Announcement.PriorityEnum.Medium == 4c02d027-2991-73eb-f8ca-f0123be92705
    • System.Announcement.PriorityEnum.Critical == 13a0d2e7-26ac-081b-aa59-e09f78adb7c9
Sign In or Register to comment.