Add attachments via web service for Request

Hello,

 

I've recently been trying to get attachements to SM 9.40 using web services, more specifically i've been trying to upload attachements using the RequestManagement.wsdl. 

Given a certain request ID , I want to be able to attach a file in PDF format to that request.

Here is the code i'm using (C#):

 

 

public UpdateRMResponse SendFiles(string RequestID, ObservableCollection<FilesToSend> fileList)
        {
            UpdateRMRequest request = new UpdateRMRequest();
            UpdateRMResponse response = new UpdateRMResponse();

            RMInstanceType instance = new RMInstanceType();
            RMModelType model = new RMModelType();
            RMKeysType keys = new RMKeysType();
            RequestManagement manage = new RequestManagement();

            manage.Credentials = new NetworkCredential("minduser", "minduser");

            StringType requestID = new StringType();
            requestID.Value = RequestID;
            
            AttachmentType[] attachArray = new AttachmentType[fileList.Count];

            for(int i = 0; i < fileList.Count; i  )
            {
                attachArray[i] = new AttachmentType();
                attachArray[i].name = fileList[i].fileName;
                attachArray[i].len = fileList[i].size;
                attachArray[i].lenSpecified = true;
                attachArray[i].type = "application/pdf";
                attachArray[i].contentType = "application/pdf";
                attachArray[i].Value = fileList[i].bytes;
                attachArray[i].action = "add";
            }

            instance.recordid = requestID.Value;
instance.attachements = attachArray; keys.Number = requestID; model.keys = keys; model.instance = instance; request.model = model; request.attachmentData = true; request.attachmentDataSpecified = true; request.ignoreEmptyElements = true; request.attachmentInfo = true; request.attachmentInfoSpecified = true; try { response = manage.UpdateRM(request); } catch (Exception ex) { response.message = ex.Message; } return response; }

Now I can update any fields just fine, the problem is when I try sending files.

I get the response from server Success but checking the record and the actual resposne object reveals that no file was actually sent. 

I've tried using SOAP UI and got the same result, tried to follow the Axis2 example which is written in java, but they do kinda what I do in my code. 

I'm quite stuck with this and could really use some insight into what exactly i'm missing here.

 

Thank you and have a nice day !

Tags: