Upload a file using C# as a Server method
I will be using a server C# method upload files for migration from a legacy PLM system.
C# method, in lieu of Batch Loader, is to used to allow more logic to be applied to the file uploading. Based on https://community.aras.com/f/development/3741/ I have simplified the code to
Innovator inn = this.getInnovator();
Item fileUpload = inn.newItem("tmp");
// File 1
Item file1 = inn.newItem("File", "add");
file1.setProperty("filename", "Comments Against V1.0.xls");
file1.setProperty("actual_filename", @"C:\Program Files (x86)\Aras\Innovator\Innovator\Server\temp\0000000000eb34");
file1.setProperty("checkedout_path", @"C:\Aras");
Item located = file1.createRelationship("Located", "add");
located.setProperty("related_id", "67BBB9204FE84A8981ED8313049BA06C"); // default vault
fileUpload.appendItem(file1);
//fileUpload.removeItem(fileUpload.getItemByIndex(0));
IomFactory factory = new IomFactory();
Aras.IOME.CheckinManager cm = factory.CreateCheckinManager(fileUpload);
return cm.Checkin(1);
Which returns an error, typically
SOAP-ENV:ServerFile with id 8F904AA99D69489BAE6F948D6A679767 cannot be found in any of its containers.File with id 8F904AA99D69489BAE6F948D6A679767 cannot be found in any of its containers.
Any suggestions?
This sample code can be used to upload a file:
// Upload this .zip to Innovator
Item zipFile = inn.newItem("File", "add");
zipFile.setProperty("filename", zipName);
zipFile.attachPhysicalFile(fullZipPath);
zipFile = zipFile.apply();