C# code to upload attachments to agile
Hi,
I am trying to create a console app to upload attachments from local disk rather than using the UI.
I am getting stuck in getContent and getAttachments section saying it is missing a reference.
However the reference has the Content and the attachments
Any help could be appreciated?
Also here is the error I am getting.
private static void addAttachment(System.Net.ICredentials cred, String classIdentifier, String partNumber, String fileName, String rev, String outpath)
{
try
{
AttachmentService.AttachmentService service = new AttachmentService.AttachmentService();
service.Url = config.Url + “/Attachment”;
service.Credentials = cred;
AttachmentService.AddFileAttachmentRequestType AddFileAttachmentRequestType = new AttachmentService.AddFileAttachmentRequestType();
AttachmentService.AgileAddFileAttachmentRequest[] agileAddFileAttachmentRequest = new AttachmentService.AgileAddFileAttachmentRequest[1];
agileAddFileAttachmentRequest[0] = new AttachmentService.AgileAddFileAttachmentRequest();
agileAddFileAttachmentRequest[0].classIdentifier = classIdentifier;
agileAddFileAttachmentRequest[0].objectNumber = partNumber;
AttachmentService.PropertyType[] options = new AttachmentService.PropertyType[1];
options[0] = new AttachmentService.PropertyType();
options[0].propertyName = “revision”;
options[0].propertyValue = rev;
agileAddFileAttachmentRequest[0].options = options;
AttachmentService.AgileAddFileAttachmentRequestType[] attachments = new AttachmentService.AgileAddFileAttachmentRequestType[1];
attachments[0] = new AttachmentService.AgileAddFileAttachmentRequestType();
agileAddFileAttachmentRequest[0].attachments = attachments;
AddFileAttachmentRequestType.requests = agileAddFileAttachmentRequest;
AttachmentService.AddFileAttachmentResponseType addFileAttachmentResponseType = service.addFileAttachment(AddFileAttachmentRequestType);
String statusCode = addFileAttachmentResponseType.statusCode.ToString();
FileDataSource datasource = new FileDataSource(fileName);
attachments[0].getContent(new DataHandler(datasource));
agileAddFileAttachmentRequest[0].getAttachments().add(attachments);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return;
}
}
Error CS1061 ‘AgileAddFileAttachmentRequest’ does not contain a definition for ‘getAttachments’ and no accessible extension method ‘getAttachments’ accepting a first argument of type ‘AgileAddFileAttachmentRequest’ could be found (are you missing a using directive or an assembly reference?) AgileAddAttach C:\Users\sthomas\Documents\AgileAddAttach\AgileAddAttach\AgileAddAttach\Program.cs 152 Active
Error CS1061 ‘AgileAddFileAttachmentRequestType’ does not contain a definition for ‘getContent’ and no accessible extension method ‘getContent’ accepting a first argument of type ‘AgileAddFileAttachmentRequestType’ could be found (are you missing a using directive or an assembly reference?) AgileAddAttach C:\Users\sthomas\Documents\AgileAddAttach\AgileAddAttach\AgileAddAttach\Program.cs 151 Active