Cannot update cm:title/description on a node with cm:versionable via REST API

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Cannot update cm:title/description on a node with cm:versionable via REST API

Jump to solution

I'm using the following endpoint to update a node:

https://api-explorer.alfresco.com/api-explorer/#!/nodes/updateNode

{
  "properties": [
    "cm:title": "New Title",
    "cm:description": "New Description",
    "cm:author": "New Author",
  ]
}

This works fine on nodes without versions. However, if a node has cm:versionable, it only updates cm:author but title and description remain the same. Tagging (which is done in a separate step) also works fine.

I also tried sending cm:versionLabel/versionType along but this also didn't help.
Neither by setting the same or higher version label.

Any help is highly appreciated!

1 Solution

Accepted Solutions
Highlighted
Community Manager
Community Manager

Re: Cannot update cm:title/description on a node with cm:versionable via REST API

Jump to solution

Hi,

I've just tried again using the api-explorer - http://localhost/api-explorer/#!/nodes/updateNode.

Using the PUT cmd I've been able to update cm:title & cm:description of a versioned document.

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic YWRtaW46YWRtaW4=' -d '{
  
  "properties":
  {
    "cm:title":"My NEW title",
    "cm:description":"This is an important doc"
  }
}' 'http://localhost/alfresco/api/-default-/public/alfresco/versions/1/nodes/3f43567d-a3ae-4b79-b56c-d52157defe9d'

Request URL:

http://localhost/alfresco/api/-default-/public/alfresco/versions/1/nodes/3f43567d-a3ae-4b79-b56c-d52157defe9d

Response body:

{
  "entry": {
    "isFile": true,
    "createdByUser": {
      "id": "admin",
      "displayName": "Administrator"
    },
    "modifiedAt": "2020-04-23T13:26:54.465+0000",
    "nodeType": "cm:content",
    "content": {
      "mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
      "mimeTypeName": "Microsoft Word 2007",
      "sizeInBytes": 48,
      "encoding": "UTF-8"
    },
    "parentId": "479ec2bc-fb73-4e93-9c44-b36d08ba0446",
    "aspectNames": [
      "rn:renditioned",
      "cm:versionable",
      "cm:titled",
      "cm:auditable",
      "cm:taggable",
      "cm:rateable",
      "cm:likesRatingSchemeRollups",
      "cm:author",
      "cm:thumbnailModification"
    ],
    "createdAt": "2020-04-03T13:46:54.555+0000",
    "isFolder": false,
    "modifiedByUser": {
      "id": "admin",
      "displayName": "Administrator"
    },
    "name": "rename file",
    "id": "3f43567d-a3ae-4b79-b56c-d52157defe9d",
    "properties": {
      "cm:title": "My NEW title",
      "cm:versionType": "MINOR",
      "cm:versionLabel": "2.1",
      "cm:author": "BoPeep 3",
      "cm:likesRatingSchemeTotal": 1,
      "cm:likesRatingSchemeCount": 1,
      "cm:lastThumbnailModification": [
        "pdf:1587645057519",
        "doclib:1587645059840"
      ],
      "cm:description": "This is an important doc"
    }
  }
}

Payload body

{
  "properties":
  {
    "cm:title":"My NEW title",
    "cm:description":"This is an important doc"
  }
}

What version of Alfresco are you running? I'm running 6.2 GA201911.

 

 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

View solution in original post

6 Replies
Highlighted
Community Manager
Community Manager

Re: Cannot update cm:title/description on a node with cm:versionable via REST API

Jump to solution

Hi,

Have you had a look at the Rest API series - part 5 discusses locking & versioning? I believe the correct PUTT call is http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/{id}  - more info here.

HTH,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
Highlighted
Active Member

Re: Cannot update cm:title/description on a node with cm:versionable via REST API

Jump to solution

Thanks a lot for your reply.

This is actually what I'm currently doing.
The request itself works fine on unversioned nodes and I don't really want to create a new version or anything like that. I just want to update properties of the current version. I also don't get an error back from the API. It just didn't apply some of the properties I sent.

This is the node I PUT to:

{
    "isFile": true,
    "createdByUser": {
        "id": "U1627",
        "displayName": "John Doe"
    },
    "modifiedAt": "2020-04-22T11:33:02.817+0000",
    "nodeType": "cm:content",
    "content": {
        "mimeType": "application\/pdf",
        "mimeTypeName": "Adobe PDF Document",
        "sizeInBytes": 115669,
        "encoding": "UTF-8"
    },
    "parentId": "95b9880d-6869-47e2-9353-c878ee7ced60",
    "aspectNames": [
        "rn:renditioned",
        "cm:versionable",
        "cm:titled",
        "cm:auditable",
        "cm:taggable",
        "cm:author",
        "cm:thumbnailModification"
    ],
    "createdAt": "2020-01-07T09:37:26.247+0000",
    "isFolder": false,
    "modifiedByUser": {
        "id": "U1627",
        "displayName": "John Doe"
    },
    "name": "Test.pdf",
    "id": "c30f7faf-2b5b-454d-aaac-a1e940c7330e",
    "properties": {
        "cm:title": "Old Title",
        "cm:versionType": "MINOR",
        "cm:versionLabel": "1.3",
        "cm:author": "New Author",
        "cm:lastThumbnailModification": [
            "doclib:1587546256239",
            "imgpreview:1587546256672"
        ],
        "cm:description": "Old Description",
        "cm:taggable": [
            "db4fccfe-b850-4eff-a5dd-5fcdfb8e15d9"
        ]
    }
}

This is my payload:

{
  "properties": [
    "cm:title": "New Title",
    "cm:description": "New Description",
    "cm:author": "New Author",
  ]
}

 As you can see, cm:author got updated, but title and description are still "old".

Highlighted
Community Manager
Community Manager

Re: Cannot update cm:title/description on a node with cm:versionable via REST API

Jump to solution

Hi @sboesch,

I actually experienced the same result as you did with that call.

However, I've just updated a versioned document's cm:title & cm:description using the following API call:

http://localhost/alfresco/s/api/metadata/node/workspace/SpacesStore/3f43567d-a3ae-4b79-b56c-d52157defe9d?alf_ticket=TICKET_007669d537dd0bff8507331d9da1362ed5dcdec4

The node I PUT to is:

 
 
{
    "nodeRef": "workspace://SpacesStore/3f43567d-a3ae-4b79-b56c-d52157defe9d",
    "aspects": [
        "rn:renditioned",
        "cm:versionable",
        "cm:titled",
        "sys:cascadeUpdate",
        "cm:auditable",
        "sys:referenceable",
        "sys:localized",
        "cm:taggable",
        "cm:author",
        "cm:thumbnailModification"
    ],
    "mimetype": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
    "type": "cm:content",
    "properties": {
        "cm:created": "2020-04-03T13:46:54.555Z",
        "cm:lastThumbnailModification": [
            "pdf:1587563780477",
            "doclib:1587563785658"
        ],
        "cm:description": "test desc using ws",
        "cm:creator": "admin",
        "sys:node-uuid": "3f43567d-a3ae-4b79-b56c-d52157defe9d",
        "cm:name": "rename file",
        "cm:content": "contentUrl=store://2020/4/22/13/56/1189b2f1-23c6-4520-a3eb-4098079935e1.bin|mimetype=application/vnd.openxmlformats-officedocument.wordprocessingml.document|size=3560|encoding=UTF-8|locale=en_US_|id=325",
        "sys:store-identifier": "SpacesStore",
        "cm:versionLabel": "2.0",
        "sys:cascadeCRC": 2463522156,
        "cm:autoVersion": true,
        "cm:initialVersion": true,
        "cm:versionType": "MAJOR",
        "cm:autoVersionOnUpdateProps": false,
        "cm:title": "a title updated by API call",
        "sys:cascadeTx": 101,
        "cm:taggable": null,
        "sys:store-protocol": "workspace",
        "sys:node-dbid": 949,
        "sys:locale": "en_US",
        "cm:modifier": "admin",
        "cm:modified": "2020-04-22T16:26:09.217Z",
        "cm:author": "Eddie May"
    }
}

My payload was:

{
	"properties":{
		"cm:name": "rename file",
		"cm:title": "a title updated by API call",
		"cm:description": "test desc using ws"
	}
}

I'm not sure if this means you have to use this particular API call to update versioned documents? I'll take a further look around and update if I discover more.

Cheers,

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
Highlighted
Active Member

Re: Cannot update cm:title/description on a node with cm:versionable via REST API

Jump to solution

Thank you very much for looking into this.

I tried your alternative API call and noticed it only supports POST instead of PUT.
However, I still get the same results - cm:author gets updated, but cm:title and description not.

I'll check it again, to see if I missed something.

Highlighted
Community Manager
Community Manager

Re: Cannot update cm:title/description on a node with cm:versionable via REST API

Jump to solution

Hi,

I've just tried again using the api-explorer - http://localhost/api-explorer/#!/nodes/updateNode.

Using the PUT cmd I've been able to update cm:title & cm:description of a versioned document.

curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Basic YWRtaW46YWRtaW4=' -d '{
  
  "properties":
  {
    "cm:title":"My NEW title",
    "cm:description":"This is an important doc"
  }
}' 'http://localhost/alfresco/api/-default-/public/alfresco/versions/1/nodes/3f43567d-a3ae-4b79-b56c-d52157defe9d'

Request URL:

http://localhost/alfresco/api/-default-/public/alfresco/versions/1/nodes/3f43567d-a3ae-4b79-b56c-d52157defe9d

Response body:

{
  "entry": {
    "isFile": true,
    "createdByUser": {
      "id": "admin",
      "displayName": "Administrator"
    },
    "modifiedAt": "2020-04-23T13:26:54.465+0000",
    "nodeType": "cm:content",
    "content": {
      "mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
      "mimeTypeName": "Microsoft Word 2007",
      "sizeInBytes": 48,
      "encoding": "UTF-8"
    },
    "parentId": "479ec2bc-fb73-4e93-9c44-b36d08ba0446",
    "aspectNames": [
      "rn:renditioned",
      "cm:versionable",
      "cm:titled",
      "cm:auditable",
      "cm:taggable",
      "cm:rateable",
      "cm:likesRatingSchemeRollups",
      "cm:author",
      "cm:thumbnailModification"
    ],
    "createdAt": "2020-04-03T13:46:54.555+0000",
    "isFolder": false,
    "modifiedByUser": {
      "id": "admin",
      "displayName": "Administrator"
    },
    "name": "rename file",
    "id": "3f43567d-a3ae-4b79-b56c-d52157defe9d",
    "properties": {
      "cm:title": "My NEW title",
      "cm:versionType": "MINOR",
      "cm:versionLabel": "2.1",
      "cm:author": "BoPeep 3",
      "cm:likesRatingSchemeTotal": 1,
      "cm:likesRatingSchemeCount": 1,
      "cm:lastThumbnailModification": [
        "pdf:1587645057519",
        "doclib:1587645059840"
      ],
      "cm:description": "This is an important doc"
    }
  }
}

Payload body

{
  "properties":
  {
    "cm:title":"My NEW title",
    "cm:description":"This is an important doc"
  }
}

What version of Alfresco are you running? I'm running 6.2 GA201911.

 

 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

View solution in original post

Highlighted
Active Member

Re: Cannot update cm:title/description on a node with cm:versionable via REST API

Jump to solution

Alright, apparently we are still on Version 5.2.e/f. We'll try to update.
Thanks for your effort.