Previous Topic: attachURLLinkToTicketNext Topic: removeAttachment


createAttachment

The following parameters apply to the createAttachment method:

Parameter

Data Type

Description

SID

INTEGER

Identifies the session retrieved from logging in.

repositoryHandle

STRING

Identifies the object handle of a document repository.

objectHandle

STRING

Identifies the object handle of a call request, change order, or issue, to which this attachment is attached.

This parameter can be NULL, however, you must manage the attachment ID that is returned because the attachment is not associated to a ticket when NULL is passed in.

description

STRING

Identifies the description for the attachment object.

fileName

STRING

Identifies the full path of the file to be uploaded.

Description

Uploads a file to the back-end server. An uploaded file is stored in a document repository specified by the repositoryHandle. An attachment object is then created and attached to a ticket object specified by the objectHandle. The attachment object has all the information for accessing the newly uploaded file in the repository.

Returns

createAttachment has the following returns:

Parameter

Type

Description

<Handle>

STRING

Identifies the object handle of the newly created attachment object.

Could not perform the operation, policy limit exceeded

Symptom:

When using the createAttachment() web service method to attach a document to an existing request or incident, you receive this error, even when the web services policy setting for attachments is set to -1(unlimited), which is the out-of-the-box default setting. You may receive this error when calling the web service method when there are no attached files in the received SOAP message. You must attach at least one file to the SOAP message before calling the createAttachment() web service method.

Solution:

Set your SOAP implementation to support Direct Internet Message Encapsulation (DIME), and attach the file to be uploaded manually using DIME support before calling the createAttachment() method.

You can refer to the examples on how to support DIME from the $NX_ROOT\samples\sdk\websvc\java\test3_attachments directory.

Example: Visual Basic .NET

This code example illustrates sample Visual Basic .NET code to attach a file using DIME support before calling the createAttachment() web service method.

Dim reqContext As SoapContext = objUSD_WS.RequestSoapContext
Dim dimeAttach As New DimeAttachment("image/gif",
TypeFormat.MediaType, "c:\test.txt")
reqContext.Attachments.Add(dimeAttach)

strResult = objUSD_WS.createAttachment(sid, "doc_rep:1002",
"cr:400001", "my desc", "c:\test.txt")

Note: For information about the DIME attachment methods used in the previous sample code, see the Microsoft website. For programs written in other languages, see your documentation for the SOAP implementation that supports DIME.

Example: Java

This code example illustrates sample Java code to attach a file using DIME support before calling the createAttachment() web service method.

FileDataSource fds = new FileDataSource(filename);
DataHandler dhandler = new DataHandler(fds);
usd._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT,
Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);
usd.addAttachment(dhandler);

String handle = usd.createAttachment(sid, repHandle, objHandle,
description, filename);