08-04-2017 02:42 AM
i am trying to update the name of a document in alfresco using the webscript :
POST /alfresco/service/api/node/content/workspace/SpacesStore/
i am getting a 405 responce from the server .
is this the right webscript to update a node properties ?
this is the code i am using to send the request
HttpPost httppost = new HttpPost(urlString);
JSONObject json = new JSONObject();
json.put("ContentType", "application/json");
json.put("name", "yosri");
HttpEntity e = new StringEntity(json.toString());
httppost.setEntity(e);
HttpResponse response = httpclient.execute(httppost);
08-17-2017 05:19 AM
SpacesStore
08-04-2017 03:54 AM
Hi yosrioh_
You cannot update properties this way. You can use instead
POST /alfresco/s/api/metadata/node/{store_type}/{store_id}/{id}
If you're using a recent Alfresco version (5.2.something) you can then use the newer v1 API:
Alfresco Content Services REST API Explorer
Or you can write a tiny webscript using java or javascript API to match exactly your needs.
08-04-2017 04:43 AM
hello
thx for your answer i tried POST /alfresco/s/api/metadata/node/{store_type}/{store_id}/{id} and i got a 200 responce from server but the document title isn't changing
is there a problem with the Json object im sending ?
JSONObject json = new JSONObject();
json.put("ContentType", "application/json");
json.put("fileName", "yosri");
HttpEntity e = new StringEntity(json.toString());
httppost.setEntity(e);
HttpResponse response = httpclient.execute(httppost);
08-04-2017 05:04 AM
Yes you need a json object as expected by the webscript. It must contains a "properties" element and appropriate properties set in it.
Something like:
{
"properties": {
"cm:description": "Some desc"
}
}
08-07-2017 03:39 AM
hello
thx for your answer i tried to put a json format like you suggested but i got a 404 not a valid node
i am using this exemple i found
what im i doing wrong ?
Abdera abdera = new Abdera();
AbderaClient client = new AbderaClient(abdera);
String uri = "http://192.168.100.231:8080/alfresco/service/api/metadata/node/workspace/SpaceStore/"+nodeRef+"?alf_ticket="+ticket;
uri = uri.replaceAll("\"", "");
String jsonMessage ="{\"properties\":{\"cm:title\":\"Texas\",\"cm:description\":\"Descripcion de Texas\"}}";
InputStream is =new ByteArrayInputStream(jsonMessage.getBytes(StandardCharsets.UTF_8));
RequestOptions options = new RequestOptions();
options.setHeader("Content-Type", "application/json");
ClientResponse c= client.post(uri, is, options);
System.out.println( c.getStatus());
Explore our Alfresco products with the links below. Use labels to filter content by product module.