cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload document with custom property

MOH_MCT
Champ in-the-making
Champ in-the-making

Hi,

I am using Rest API to upload a document i.e POST /nodes/{nodeid}. My question here is how to set a custom property with a document that is defined under the content model.

8 REPLIES 8

EddieMay
World-Class Innovator
World-Class Innovator

Hi @MOH_MCT,

If you have a custom model, I believe you can reference your custom model like so: 

"nodeType=acme:document" 

You can see the documentation here.

To add/update custom properties you would add something like this:

"properties": {
      "cm:title": "My text",
      "acme:securityClassification": "Public",
      "cm:versionType": "MAJOR",
      "acme:documentId": "DOC001",
      "cm:versionLabel": "1.0",
      "cm:description": "My custom text document description"
    }

 In the example above you can see that the "acme" content model has a "documentId" custom property/metadata. 

HTH,

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

MOH_MCT
Champ in-the-making
Champ in-the-making

Hi @EddieMay 

With POST call /node/nodeid i am unable to add custom property.

For that i am invoking two rest calls one post is for upload and second put call for adding custom property.

MOH_MCT
Champ in-the-making
Champ in-the-making

Hello,

Any update?

EddieMay
World-Class Innovator
World-Class Innovator

Hi @MOH_MCT,

I've just run some tests using Postman on the latest Community Edition (201911 GA). What I've done is create a custom model (following the standard examples at https://docs.alfresco.com/6.2/concepts/admintools-cmm-tutorial.html). So, my custom model is dc:Whitepaper, with a custom property type "dc:writer".

The ReST API code to upload a new file of type dc:Whitepaper is as follows:

POST /alfresco/api/-default-/public/alfresco/versions/1/nodes/-my-/children?autoRename=true&alf_ticket=TICKET_81eec01da4c0a37a4a746f5554bb8af7f4f0b1a4 HTTP/1.1
Host: localhost:80
Authorization: Basic dGVzdDp0ZXN0
Content-Type: application/json
Content-Type: text/plain

{
	"name": "content-to-be-deleted3.txt",
	"nodeType": "dc:Whitepaper",
	 "properties": {
            "dc:writer": "Eddie"
           
        }
	
}

The file has been uploaded and the type & properties set accordingly.

imageWriter property set

HTH,

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

MOH_MCT
Champ in-the-making
Champ in-the-making

Hi @EddieMay 

We followed the same steps to create a custom model as per document the same payload but still, we are not able to set property.

URI-/alfresco/api/-default-/public/alfresco/versions/1/nodes/708502be-96ff-46c2-95e9-9d07676189c4/children

Payload used-{
"nodeType": "dc:whitePaper",
"properties": {
"dc:writer": "Eddie"
}
}

After uploading property not reflected. Can you please check?

EddieMay
World-Class Innovator
World-Class Innovator

Hi @MOH_MCT,

Can you look up the model and its properties using the Node Browser? This should display the type & properties in case anything is not being displayed properly in Share.

imageNode Browser view 

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

MOH_MCT
Champ in-the-making
Champ in-the-making

Hi @EddieMay 

I am attaching screenshots for input and output. As even call is successful property is not getting reflected in POST call.

If we trigger the same document based on node id with PUT call property is getting reflected here we are giving the same JSON.

Also attaching a screenshot for file displaying property after POST call.

Please let me know if we can connect our Webex?

image

image

image

andrakula
Champ on-the-rise
Champ on-the-rise

hello @MOH_MCT, have you solved this problem?

Pleas let my know your solution.