AnsweredAssumed Answered

DotCMIS API + Getting the folder details

Question asked by rita_aiyar on Nov 28, 2014
Latest reply on Apr 21, 2015 by mattfisch34

I am using the following url http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom in my dotnet code.
When I create my session object and do a session.GetObjectByPath("/Repository/Test Folder") an error is thrown "Bad Request".

However when i use this url https://localhost:8080/alfresco/service/cmis , session.GetObjectByPath("/Repository/Test Folder") works as expected.

Below is my code. Please let me know what i am doing wrong.

private static ISession GetSession()
    Dictionary<string, string> parameters = new Dictionary<string, string>();

    parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;

    parameters[DotCMIS.SessionParameter.AtomPubUrl] = "https://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom";

    parameters[DotCMIS.SessionParameter.User] = "admin";

    parameters[DotCMIS.SessionParameter.Password] = "admin";
    SessionFactory factory = SessionFactory.NewInstance();

    IList<IRepository> repos = factory.GetRepositories(parameters);

    ISession session = repos.ElementAt(0).CreateSession();
    return session;

protected void btnUpload_Click(object sender, EventArgs e)
    ISession session = GetSession();
    IOperationContext oc = session.CreateOperationContext();
    IFolder root = session.GetRootFolder();
    IDictionary<string, object> properties = new Dictionary<string, object>();

    properties.Add(PropertyIds.Name, "Test2.txt");
    properties.Add(PropertyIds.ObjectTypeId, "cmis:document");

    FileStream fs = File.OpenRead(@"C:\Users\ritaaiya\Desktop\Test\Test2.txt");

    byte[] bytes = new byte[fs.Length];
    fs.Read(bytes, 0, Convert.ToInt32(fs.Length));

    ContentStream contentStream = new ContentStream
        FileName = "Test2.txt",
        MimeType = "text/plain",
        Length = bytes.LongLength,
        Stream = new MemoryStream(bytes)

       //Below 2 statements throw an error
        ICmisObject rootFolder = session.GetObjectByPath("Repository/Reference Library/Human Resources/Training Plan");

        ICmisObject rootFolder1 = session.GetObjectByPath("/Repository");

        //This works
        //ICmisObject rootFolder = session.GetObject("workspace://SpacesStore/4beeecd9-8ced-4b57-8ae4-e6c3d8cf85e8");


        IFolder iFolder = rootFolder as IFolder;
        IDocument doc = iFolder.CreateDocument(properties, contentStream, VersioningState.Major);
    catch (Exception ex)
        string test1 = ex.Message;