Jump to content

Recommended Posts

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?

Share this post


Link to post
Share on other sites

Hi matrojas,

 

I don't know how to do it, but you can find a working example for create a Change Order with attachment (in Java) under NX_ROOT\samples\sdk\rest\java\test3_attachments\SampleNewResourceWithAttachment.java.

 

Hope it helps!

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...