AnsweredAssumed Answered

CreateDocument in DotCMIS error 'Type or type property must be set'

Question asked by lozzad on Oct 16, 2013
Latest reply on Oct 17, 2013 by lozzad
Hi,

I am looking at creating a Word Add-in in visual studio using DotCMIS in C#.

I am using code as below which is largely taken from the CMISandApacheChemistryinAction book.

I am using DotCMIS 0.5 And Alfresco Community 4.2.d


       private void test()
       {
        Dictionary<string, string> parameters =
        new Dictionary<string, string>();
        // define binding type, in our example we are using ATOMPUB as stated above
        parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;
        // define CMIS available path which is already available under alfresco
        parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://blah:8080/alfresco/service/cmis";
        // alfresco portal admin user name
        parameters[DotCMIS.SessionParameter.User] = "admin";
        // alfresco portal admin password
        parameters[DotCMIS.SessionParameter.Password] = "admin";
        SessionFactory factory = SessionFactory.NewInstance();
        ISession session = factory.GetRepositories(parameters)[0].
        CreateSession();
        Dictionary<string, object> properties = new Dictionary<string,object>()
        {
        {"cmis:name", "exampleName" },
        {"cmis:objectType", "cmis:document"},
        };

        IFolder rootFolder = session.GetRootFolder();
        string filePath = "\\exampleFile";
        string fileName = "exampleFile";
        FileStream stream = File.Create(filePath);
        IObjectFactory objectFactory = session.ObjectFactory;
        IContentStream contentStream = session.ObjectFactory.
        CreateContentStream(fileName, stream.Length, "text/plain", stream);
        IDocument firstDoc = rootFolder.CreateDocument(properties, contentStream,
        VersioningState.Major);
       }


I get an error "Type or type property must be set!" on the last line of code            
IDocument firstDoc = folder.CreateDocument(properties, contentStream,
VersioningState.Major);


I have no prior experience with CMIS and just want to get something working so any help appreciated.

Outcomes