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.
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,
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.
Hello,
Any update?
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.
HTH,
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?
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.
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?
hello @MOH_MCT, have you solved this problem?
Pleas let my know your solution.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.