Json for updating meta-data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2011 07:05 AM
I am calling the following service with posting the json file containing the metadata.
http://192.168.100.106:8180/alfresco/service/api/metadata/node/workspace/SpacesStore/67f7081b-7236-4...
and getting the response as success. but still alfresco is not updating the meta data of the documents.
so i think there is the problem with my json format. i have tried various formats but none worked.
so can someone please help me what json is needed for updating meta-data of the documents.
Thanks in advance,
arpit
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2011 08:17 AM
Which script are you using and what are you posting to it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2011 08:29 AM
i am using default meta data storage script. Description can be found here http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Node_Metadata_Storage_Service.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2011 08:42 AM
File: org/alfresco/repository/metadata/metadata.post.json.js
main();function main(){ if (url.templateArgs.store_type === null) { status.setCode(status.STATUS_BAD_REQUEST, "NodeRef missing"); return; } // nodeRef input var storeType = url.templateArgs.store_type; var storeId = url.templateArgs.store_id; var id = url.templateArgs.id; var nodeRef = storeType + "://" + storeId + "/" + id; var node = search.findNode(nodeRef); if (node === null) { status.setCode(status.STATUS_NOT_FOUND, "Not a valid nodeRef: '" + nodeRef + "'"); return null; } // Set passed-in properties if (json.has("properties")) { var properties = jsonToObject("properties"); for (property in properties) { node.properties[property] = properties[property]; } } // Set passed-in mimetype if (json.has("mimetype")) { node.mimetype = json.get("mimetype"); } // Set passed-in tags if (json.has("tags")) { // Get the tags JSONArray and copy it to a native JavaScript array var jsonTags = json.get("tags"), tags = []; for (var t = 0; t < jsonTags.length(); t++) { tags.push(jsonTags.get(t)); } if (tags.length > 0) { node.tags = tags; } else { node.clearTags(); } } node.save();}function jsonToObject(p_name){ var object = {}; var jsonObj = json.get(p_name); var names = jsonObj.names(); var name; for (var i = 0, j = names.length(); i < j; i++) { name = names.get(i); object[name] = jsonObj.get(name); } return object;}function jsonToArray(p_name){ var array = []; var jsonArray = json.get(p_name); for (var i = 0, j = jsonArray.length(); i < j; i++) { array.push(jsonArray.get(i)); } return array;}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2011 09:24 AM
{
"properties":{
"{http://www.alfresco.org/model/content/1.0}agreement_id':'1234",
"{http://www.alfresco.org/model/content/1.0}property_id':'4567"
}
}
but still it's not working.
am i missing something?
please help me out…
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2011 07:34 AM
I have the same problem although I using Java and do not working in spite of this, the return message is always "success"…
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2011 04:30 AM
I was not setting the request content type correctly.
StringEntity entity = new StringEntity(getMetaDataAsJson(metadata));
entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
This resolved my problem…
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2011 08:01 AM
This has been the clue to resolve my problem.
An example just in case somebody uses Abdera o similar to the operation in Java:
Abdera abdera = new Abdera();AbderaClient client = new AbderaClient(abdera);String uri = "http://localhost:8080/alfresco/service/api/metadata/node/workspace/SpaceStore/{id}?alf_ticket=ticket";String jsonMessage ="{\"properties\":{\"cm:title\":\"Texas\",\"cm:description\":\"Descripción de Texas\"}}";InputStream is = Utilidades.stringToInputStream(jsonMessage);RequestOptions options = new RequestOptions();options.setHeader("Content-Type", "application/json");ClientResponse resp = client.post(uri, is, options);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2015 06:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2015 07:25 AM
HTTP/1.1 404 Not Foundbody { "status" : { "code" : 404, "name" : "Not Found", "description" : "Requested resource is not available." }, "message" : "Not a valid nodeRef: 'workspace:\/\/SpaceStore\/de17d530-1f13-4eb1-91b5-7049892a5055\/'", "exception" : "", "callstack" : [ ], "server" : "Community v5.0.0 (c r91299-b145) schema 8,009", "time" : "Apr 24, 2015 4:21:29 AM"}
Here is the code
urlString = "http://'+ipaddress+':8080/alfresco/service/api/metadata/node/workspace/SpaceStore/'+nodeId+'/?alf_ti..." + authTicket; System.out.println("The upload url:::" + urlString); client = new HttpClient(); mPost = new PostMethod(urlString); itemNameValue=new ArrayList(); itemNameValue.addAll(Arrays.asList(new String[] { "Item1","Item2"})); String jsonMessage ="{\"properties\":{\"rs:vendor\":\"Texas\",\"rs:itemName\":\"Descripción de Texas\"}}"; InputStream stream = new ByteArrayInputStream(jsonMessage.getBytes(StandardCharsets.UTF_8)); mPost.addRequestHeader("Content-Type", "application/json"); mPost.setRequestBody(stream); statusCode1 = client.executeMethod(mPost); System.out.println("statusLine>>>" + statusCode1 + "……" + "\n status line \n" + mPost.getStatusLine() + "\nbody \n" + mPost.getResponseBodyAsString()); mPost.releaseConnection();