How To Use SOAPUI To Attach A File To A Ticket

Document ID : KB000092695
Last Modified Date : 20/04/2018
Show Technical Document Details
Introduction:
Soapui is a common for administrators and programmers to test or even perform real operations for Service Desk/CMDB soap web service API methods.
Very often, users may just try to enter the full path name in the fileName argument and this will result in error " Error - could not perform the operation, policy limit exceeded". This tech doc explains what additional steps would need to do successful attachments. 
For createAttachment() syntax, please refer to
https://docops.ca.com/ca-service-management/17-0/en/reference/ca-service-desk-manager-reference-commands/technical-reference/web-services-attachment-related-methods
Question:
How To Use SOAPUI To Attach A File To A Ticket
Environment:
Service Management Service Desk/CMDB 12.9, 14.1, 17.x on Windows/Unix/Linux
Answer:
createAttachment() can be used to attach a file to an existing ticket. Please take a look at this example:

User-added image

Please notice that the repHandle is the attachment repository handle. Usually it is the handle for Service Desk repository so it is static and you can hard code it as "doc_rep:xxxxx". For example, running
pdm_extract -f "select persid from Document_Repository where sym='Service Desk'"
TABLE Document_Repository

        persid
        { "doc_rep:1002" }
Document_Repository
        rows:1
shows you can hard code it as "doc_rep:1002".
Also notice that the objectHandle is the ticket handle/persid such as "cr:xxxxx", "chg:xxxx" etc. And again you could use the pdm_extract to retrieve this
value if you know the ticket number. For example, for call request 46, you could run
pdm_extract -f "select persid from Call_Req where ref_num='46'"
TABLE Call_Req
        persid
        { "cr:400307" }
Call_Req
        rows:1
and you use the value "cr:400307" for it.
And fileName explains itself.
After all these ready, click on the Attachments tab and then click on the "+" sign to choose the file you specify in the fileName value. The content type would need to match the file type of fileName file. For more details, refer to this info
https://www.soapui.org/docs/soap-and-wsdl/attachments.html
and once all these are done, run the request and if it runs fine, you will see the returned attachment persid as attamnt:xxxx