Hello,
I created a folder rule that executes a JS script.
In this script, i'm trying to POST the document's ID in ODOO api using the following code:
var nid = document.properties['cm:nid']; var url = "http://localhost../api/alfresco/create"; var data = { "node_id": nid }; var headers = { "Content-Type": "application/json", "Accept": "application/json" }; var http = new Packages.org.apache.commons.httpclient.HttpClient(); var post = new Packages.org.apache.commons.httpclient.methods.PostMethod(url); post.setRequestEntity(new Packages.org.apache.commons.httpclient.methods.StringRequestEntity(JSON.stringify(data), "application/json", "UTF-8")); for (var key in headers) { if (headers.hasOwnProperty(key)) { post.addRequestHeader(key, headers[key]); } } try { var status = http.executeMethod(post); logger.log("API response status: " + status); logger.log("API response body: " + post.getResponseBodyAsString()); } catch (ex) { logger.log("Error sending POST request to API: " + ex); } finally { post.releaseConnection(); }
I tested this script in Javascript Console it works good, but when i try to execute it when adding a document, it shows the following error:
What might be the problem here? Am I using the wrong packages?
Please check alfresco log. There you will get idea why it is failing.
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.