cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco API to get custom metadata

ramyapratyusha
Champ in-the-making
Champ in-the-making
We are moving to Alfresco Content Management system and there is no direct documentation for retrieving custom metadata.

Is there a way to get custom metadata/ custom properties that I have added to Record category in Alfresco Records Management File plan? Custom metadata is basically the data fields that are in scanned document like name, dob, form id, etc.

Eg: I have created RM site and added the following file plan.

 TestCategory
|
–TestFolder1
  |
  –Record1
  –Record2
|
–TestFolder2
  |
  –Record1
  –Record2


These records contains uploaded form(scanned document) along with metadata (custom).

To Retrieve metadata, am using

http://127.0.0.1:8090/alfresco/service/api/metadata/node/workspace/SpacesStore/ed6e2cc6-6dc5-4bfb-bf...
It is returning 405-Method not allowed (GET not supported).

To Retrieve all the subfolders/documents in Folders, m using

http://127.0.0.1:8090/alfresco/service/slingshot/doclib/doclist/documents/site/rm/documentLibrary/Te...
Above one returns


{
  "totalRecords": 1,
  "startIndex": 0,
  "metadata": {
    "repositoryId": "3b9d4f67-dc84-4531-b8b2-4dbcef15e25a",
    "container": "workspace://SpacesStore/7d1349bb-5289-4709-9055-c75c03ab5481",
    "parent": {
      "nodeRef": "workspace://SpacesStore/5d40660e-64d9-4bc4-a75e-ae4ae8b2201a",
      "permissions": {
        "userAccess": {
          "create": true,
          "edit": true,
          "delete": true,
          "cancel-checkout": false,
          "permissions": true
        }
      }
    },
    "onlineEditing": true,
    "itemCounts": {
      "folders": 0,
      "documents": 1
    }
  },
  "items": [
    {
      "nodeRef": "workspace://SpacesStore/65b9b52b-3418-4a85-98b0-d4770cf9399d",
      "nodeType": "cm:content",
      "type": "document",
      "mimetype": "application/pdf",
      "isFolder": false,
      "isLink": false,
      "fileName": "BO (2016-1464237424392).pdf",
      "displayName": "BO (2016-1464237424392).pdf",
      "status": "",
      "title": "þÿ",
      "description": "test description",
      "author": "",
      "createdOn": "2016-05-26T00:37:04.350-04:00",
      "createdBy": "Administrator",
      "createdByUser": "admin",
      "modifiedOn": "2016-05-31T15:50:21.269-04:00",
      "modifiedBy": "Administrator",
      "modifiedByUser": "admin",
      "lastThumbnailModification": "doclib:1464237426243",
      "lockedBy": "",
      "lockedByUser": "",
      "size": "156702",
      "version": "1.0",
      "contentUrl": "api/node/content/workspace/SpacesStore/65b9b52b-3418-4a85-98b0-d4770cf9399d/BO%20(2016-1464237424392).pdf",
      "webdavUrl": "/webdav/Sites/rm/documentLibrary/TestCat1/TestFolder2/BO%20(2016-1464237424392).pdf",
      "actionSet": "document",
      "tags": [],
      "activeWorkflows": "",
      "isFavourite": false,
      "likes": {
        "isLiked": false,
        "totalLikes": 0
      },
      "location": {
        "repositoryId": "3b9d4f67-dc84-4531-b8b2-4dbcef15e25a",
        "site": "rm",
        "siteTitle": "Records Management",
        "container": "documentLibrary",
        "path": "/TestCat1/TestFolder2",
        "file": "BO (2016-1464237424392).pdf",
        "parent": {
          "nodeRef": "workspace://SpacesStore/5d40660e-64d9-4bc4-a75e-ae4ae8b2201a"
        }
      },
      "permissions": {
        "inherited": true,
        "roles": [
          "ALLOWED;ROLE_EXTENDED_READER;ReadRecords;INHERITED",
          "ALLOWED;GROUP_Administrator7d1349bb-5289-4709-9055-c75c03ab5481;Filing;INHERITED",
          "ALLOWED;ROLE_EXTENDED_WRITER;Filing;INHERITED"
        ],
        "userAccess": {
          "create": true,
          "edit": true,
          "delete": true,
          "cancel-checkout": false,
          "permissions": true
        }
      },
      "custom": {},
      "actionLabels": {}
    }
  ]
}



Using PostMan chrome app to test rest api. TIA.
4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator
Hello,

well, there is rather complete documentation about a standard API to access documents and metadata. That API is called CMIS. It is documented both <a href="http://docs.alfresco.com/5.1/pra/1/topics/cmis-welcome.html">in the Alfresco documentation</a> and <a href="http://docs.oasis-open.org/cmis/CMIS/v1.1/CMIS-v1.1.html">by itself</a>.
You should not use the Alfresco internal ReST endpoints for application integration as these endpoints may change between Alfresco versions. Only the CMIS / Public API are guaranteed to remain compatible within the specific API version.

Regards
Axel

niketapatel
Star Contributor
Star Contributor
I am not sure if there is any specific service for RM. But below service for sure will give you all metadata including your custom one.


/alfresco/service/api/metadata?nodeRef=workspace://SpacesStore/a2a6c249-c55d-4d29-8692-3e9cb1f811a8  [GET service]

Hi, Thanks. This is really helpful. Can you please let me know if there is api to get folders in a category? and files/records/documents in a folder? Once I get folders in a category, By using nodeRef of folders, I will be able to get all the documents in that folder and metadata of each document.

To achieve this, am using

 http://127.0.0.1:8090/alfresco/service/slingshot/doclib/doclist/documents/site/rm/documentLibrary/Te... folderName + "alf_ticket=" + authTicket; 


Is there a simpler way?

No. You will have to retrive this way only! Script you are using that is for Non-RM site. It also gives you required detail but this will include everything like Holds, Transfer etc. folders along with Categories. If you need specific all details related to RM then please try below one.

Detailed: Keep appending path
http://127.0.0.1:8090/share/service/components/documentlibrary/data/doclist/all/site/rm/documentLibr...

Only tree noderefs:
http://127.0.0.1:8090/share/proxy/alfresco/slingshot/doclib/rm/treenode/site/rm/documentLibrary?perm...