Home Analyst Portal

Has anyone had any luck getting the UpdateWatchlistByWorkItemId API to work?

R_DelawderR_Delawder Member Adept IT Monkey ✭✭

According to the documentation this is used to add/delete users to a watchlist.

I was trying to put together a custom task for "Add to my watchlist" but I cant get the API to return anything but false.

If so would you mind posting the format you used for it.

 

Best Answer

Answers

  • Conner_WoodConner_Wood Customer Ninja IT Monkey ✭✭✭✭
    I haven't played around with the API as I've had other priorities, however I know that you need to pass the exact parameter names as they are case sensitive, so make sure "workitemId" is capitalized where it needs to be.

    Have you used the API before at all?  I'd recommend starting calls to the Cireson Portal API with PowerShell

    Then after confirming any of the GET methods work with your script from the Cireson API Reference, I would then attempt to pass already confirmed values to the functions to ensure each one would work:
    Good Luck!

  • R_DelawderR_Delawder Member Adept IT Monkey ✭✭

    Yes, I have several custom task that use the API, I just haven't been able to get the update watchlist one to work. The getwatchlistbyworkitemid worked fine for me but not the update one.

     I haven't tried running it via PowerShell but guess I could to test it there when I have some time.

  • Conner_WoodConner_Wood Customer Ninja IT Monkey ✭✭✭✭
    Downloaded SCSM 2012 - Cireson Portal v7.3.2012.1 (Installer v7.0.6) as I noticed Cireson has updated their API from "UpdateWatchlistByWorkItemId" into 2 different calls.  I can confirm they work and here is my example code.

    [POST] AddToWatchlist
    #enter your portal URL here
    $site = "http://localhost"
    
    #Add User to a Ticket Watchlist (if user in list will return false)
    
    $url = ($site + "/api/V3/WorkItem/AddToWatchlist?workitemId=142F68DD-F1E1-3883-61EA-1436EC3436CD&userId=55ef7e06-8ee3-576f-76a7-ec858b20f751")
    
    #Try to call Function
    $response = $null
    
    try 
    { 
        $response = Invoke-RestMethod -UseDefaultCredentials -Uri $url -Method POST 
    } 
    catch 
    { 
        echo $_.Exception.Message;
    }
    
    if($response -eq $null)
    {
    	echo "Function was not executed successfully."
    }
    else
    {
    	echo "User Added: $response"
    }

    [DELETE] DeleteFromWatchlist
    #enter your portal URL here
    $site = "http://localhost"
    
    #Remove User from a Ticket Watchlist (if user not in list will return false)
    $url = ($site + "/api/V3/WorkItem/DeleteFromWatchlist?workitemId=142F68DD-F1E1-3883-61EA-1436EC3436CD&userId=55ef7e06-8ee3-576f-76a7-ec858b20f751")
    
    #Try to call Function
    $response = $null
    
    try 
    {
        $response = Invoke-RestMethod -UseDefaultCredentials -Uri $url -Method DELETE 
    } 
    catch 
    { 
        echo $_.Exception.Message;
    }
    
    if($response -eq $null)
    {
    	echo "Function was not executed successfully."
    }
    else
    {
    	echo "User Removed: $response"
    }

    Thank you Cireson workers for updating and improving the Watch List Functionality.  Great job Cireson, you have earned that compliment.

Sign In or Register to comment.