Clarity Service Management

Expand all | Collapse all

Add attachment via Rest API

  • 1.  Add attachment via Rest API

    Posted 03-28-2019 05:44 PM

    I have been successfully creating tickets in CA Service Desk using Powershell for a couple years now, but I have been tasked with figuring out how to add an attachment to the ticket.  They way I am doing it currently is, once I have the $accesskey:

     

            $URIString = "http://$servername:8050/caisd-rest/cr"

            $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
            $headers.Add("X-AccessKey", $accesskey)
            $headers.Add("Accept", "application/xml")
            $headers.Add("Content-Type", "application/xml; charset=UTF-8")
            $headers.Add("X-Obj-Attrs" , "ref_num")

            $body = "<cr><group COMMON_NAME=`"Security Admin`"/><summary>`"Test Ticket - Please Ignore`"</summary><requested_by COMMON_NAME=`"AutomationReview, UserAccess`"/><customer COMMON_NAME=`"AutomationReview, UserAccess`"/><description>`"Test Ticket - Please Ignore`"</description></cr>"

            $b = Invoke-RestMethod -Method POST -Uri $UriString -Headers $headers -body $body
           

    This works great, but I can't figure out how to add an attachment.  I tried adding "<attachment>`"C:\temp\empID.txt`"</attachment>" to the middle of the body, and while that didn't throw any errors, it didn't seem to do anything.

     

    Can anyone point me in the right direction?



  • 2.  Re: Add attachment via Rest API

    Posted 04-09-2019 11:56 AM