Hi,
I'd like to add some metadata to a file already existing on Alfresco.
I want to do it from a server-side of a node application.
I'm doing a request as following :
var request = require('request')
var r = request.put('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/'+nodeId+'?alf_ticket=..., function callback(err, httpResponse, body) {
if(err){
return console.log('Error')
}
console.log('Success')
}
var form = r.form()
form.append("myProperty", "myValue")
But it doesn't work, it return an error 400 'Could not read content from HTTP request body: No content to map to Object due to end of input'
I assume that I don't pass the right values, but I don't know how to do it so .. If anyone have a tip =)
Thanks in advance
Solved! Go to Solution.
Got it done with :
var http = require("http");
var options = {
'host': 'localhost',
'port': '8080',
'path': '/alfresco/api/-default-/public/alfresco/versions/1/nodes/'+nodeId+'?alf_ticket='+JSON.parse(chunk).data.ticket,
'method': 'PUT',
'headers': {
'Content-Type': 'application/json'
}
};var body = {
'properties':{
'cm:description': 'desc'
}
}var req = http.request(options, function(res){
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
})
})
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});req.write(JSON.stringify(body));
req.end();
Allows to update already existing properties, now looking for creating custom ones easily
Got it done with :
var http = require("http");
var options = {
'host': 'localhost',
'port': '8080',
'path': '/alfresco/api/-default-/public/alfresco/versions/1/nodes/'+nodeId+'?alf_ticket='+JSON.parse(chunk).data.ticket,
'method': 'PUT',
'headers': {
'Content-Type': 'application/json'
}
};var body = {
'properties':{
'cm:description': 'desc'
}
}var req = http.request(options, function(res){
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
})
})
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});req.write(JSON.stringify(body));
req.end();
Allows to update already existing properties, now looking for creating custom ones easily
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.