Muhammad Roshan
Muhammad Roshan

Reputation: 1

How to Create Document Library using Rest API in Alfresco

The documentLibrary is created on the first access But using HTTP GET request from Java program, the documentLibrary is not created.

Even though I faked a GET request /share/page/site/ + shortName + /documentlibrary But document folder is still not created. I can see the resulting HTML in the response. What could be the issue? Are there any javascript that runs once we first access ?

Upvotes: 0

Views: 949

Answers (2)

JazzTeam
JazzTeam

Reputation: 59

You can use the cmis family query:

nodeRef = b544cd67-e839-4c60-a616-9605fa2affb7;
xml = '<?xml version="1.0" encoding="utf-8"?>' +
     '<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/"
xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">' +
       '<title>name</title>' +
       '<summary>name</summary>' +
       '<cmisra:object>' +
       '<cmis:properties>' +
       '<cmis:propertyId propertyDefinitionId="cmis:objectTypeId">' +
       '<cmis:value>type</cmis:value>' +
       '</cmis:propertyId>' +
       '</cmis:properties>' +
       '</cmisra:object>' +
       '</entry>';
url: "/../alfresco/service/api/node/workspace/SpacesStore/" + nodeRef + "/children",
method: "POST",
headers: {
"Content-Type": "application/atom+xml;type=entry"
},
xml:xml

name - document name;

type - document type;

nodeRef - folder id in Alfresco.

To create a document in type specify cmis: document.

I also advise you to read this article, which describes the other queries: http://jazzteam.org/en/technical-articles/list-of-alfresco-services/

Upvotes: 0

alfrescian
alfrescian

Reputation: 4079

Your URL point to the Share documentLibrary Page. But the data is loaded via AJAX from the repo via the following URL: GET /share/proxy/alfresco/slingshot/doclib2/doclist/{type}/site/{shortName}/documentLibrary

AFAIK type can be: all, documents or folders

This URL may have changed in 4.2...

Upvotes: 1

Related Questions