08-15-2012 02:38 PM
Add comment
Add a new comment to a node.
POST /alfresco/service/api/node/{store_type}/{store_id}/{id}/comments
In my case, i use this format: /alfresco/service/api/node/workspace/SpacesStore/4eb045b7-8b0c-4799-9b8b-xxxxxxxxxx/comments
{
"title" : "title",
"content" : "content"
}
HTTP/1.1 500 Internal Server Error
08-15-2012 06:05 PM
08-15-2012 10:47 PM
When you use curl to do this, here's what it looks like:
curl -X POST -uadmin:admin http://localhost:8080/alfresco/s/api/node/workspace/SpacesStore/7bb9c846-fcc5-43b5-a893-39e46ebe94d4... -H "content-type:application/json" -d@/var/tmp/tmp.json
Where /var/tmp/tmp.json contains your JSON above, verbatim.
This is working fine against 4.0.d. I can test it against another version if you need me to, but you should check that you are properly setting the content-type to "application/json" as that is a common problem.
If it still doesn't work for you, please post the code that is making the POST.
Jeff
/alfresco/service/api/node/workspace/SpacesStore/4eb045b7-8b0c-4799-9b8b-xxxxxxxxxx/comments
s
in your url alfresco/s/api/node/workspace/SpacesStore/
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
String json = "{"
+ "\"title\" : \"" + title + "\","
+ "\"content\" : \"" + content+ "\""
+ "}";
StringEntity requestEntity = new StringEntity(json, "UTF-8");
httppost.setEntity(requestEntity);
httppost.setHeader("Content-type", "application/json'");
Log.i("executing request" , String.valueOf(httppost.getRequestLine()));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
System.out.println("—————————————-");
System.out.println(response.getStatusLine());
if (entity != null) {
Log.i("response content length:", entity.getContentLength() + "");
json = EntityUtils.toString(entity);
Log.i("response content:" , json);
response.getEntity().consumeContent();
}
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
{
"status" :
{
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},
08-16-2012 09:07 AM
08-16-2012 10:03 AM
Sorry, didn't mean to confuse you by using "s". It is a shortcut. It is equivalent to using "service".
I notice a strange single-quote after your content-type string:
httppost.setHeader("Content-type", "application/json'");
Can you check that?
DELETE /api/comment/node/{store_type}/{store_id}/{id}
<= HTTP status
How i can pass the id of comment08-16-2012 01:29 PM
{
"item": {
"url": "api/comment/node/workspace\/SpacesStore\/5d3f51f1-b868-40e3-80c9-890c97061d7d",
"nodeRef": "workspace://SpacesStore/5d3f51f1-b868-40e3-80c9-890c97061d7d",
"name": "comment-1345137429134",
"title": "title",
"content": "content",
"author":
{
"username": "admin",
"firstName": "Administrator",
"lastName": ""
},
"createdOn": "Aug 16 2012 12:17:09 GMT-0500 (CDT)",
"modifiedOn": "Aug 16 2012 12:17:09 GMT-0500 (CDT)",
"createdOnISO": "2012-08-16T12:17:09.136-05:00",
"modifiedOnISO": "2012-08-16T12:17:09.136-05:00",
"isUpdated": false,
"permissions":
{
"edit": true,
"delete": true
}
}
}
That nodeRef is the nodeRef of the comment node. So you can make a DELETE call using that, like this:curl -X DELETE -uadmin:admin http://localhost:8080/alfresco/s/api/node/workspace/SpacesStore/5d3f51f1-b868-40e3-80c9-890c97061d7d
08-19-2012 05:53 AM
When you post the comment you'll get JSON back that looks something like this:That nodeRef is the nodeRef of the comment node. So you can make a DELETE call using that, like this:{
"item": {
"url": "api/comment/node/workspace\/SpacesStore\/5d3f51f1-b868-40e3-80c9-890c97061d7d",
"nodeRef": "workspace://SpacesStore/5d3f51f1-b868-40e3-80c9-890c97061d7d",
"name": "comment-1345137429134",
"title": "title",
"content": "content",
"author":
{
"username": "admin",
"firstName": "Administrator",
"lastName": ""
},
"createdOn": "Aug 16 2012 12:17:09 GMT-0500 (CDT)",
"modifiedOn": "Aug 16 2012 12:17:09 GMT-0500 (CDT)",
"createdOnISO": "2012-08-16T12:17:09.136-05:00",
"modifiedOnISO": "2012-08-16T12:17:09.136-05:00",
"isUpdated": false,
"permissions":
{
"edit": true,
"delete": true
}
}
}curl -X DELETE -uadmin:admin http://localhost:8080/alfresco/s/api/node/workspace/SpacesStore/5d3f51f1-b868-40e3-80c9-890c97061d7d
08-20-2012 04:27 PM
09-09-2012 01:11 AM
"/alfresco/service/api/node/workspace/SpacesStore/{id}/ratings"
09-10-2012 01:29 PM
The favorites is used to mark a document as a favorite. In the UI it shows as a filled in star and then shows up when you filter on favorites.
[img]http://i.imgur.com/yVBPF.png[/img]
To mark a document as a favorite, you POST to:
http://localhost:8080/alfresco/s/api/people/{user id}/preferences
The following JSON:
{"org":{"alfresco":{"share":{"documents":{"favourites":"{node ref of the favorite document"}}}}}
Where "node ref of the favorite document" looks like: workspace://SpacesStore/1a0b110f-1e09-4ca2-b367-fe25e4964a4e
Jeff
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.