Is it possible to call Java Backend web script from Aikau service using Xhr. I tried it but got status code 500. When I call web script from the (Surf) document library it works. Below is my code:
define(["dojo/_base/declare",
"alfresco/services/BaseService",
"alfresco/core/CoreXhr",
"service/constants/Default",
"alfresco/core/PathUtils",
"alfresco/enums/urlTypes",
"dojo/_base/lang",
"dojo/_base/array"],
function(declare, BaseService, CoreXhr, AlfConstants, PathUtils, urlTypes, lang, array) {
return declare([BaseService, CoreXhr, PathUtils], {
constructor: function alfresco_services_BaseService__constructor(args) {
this.alfSubscribe("ADD_ITEMS_TO_LIST", lang.hitch(this, this.onAction));
},
onAction: function facetedsearch_DocumentService_onAction(payload) {
var config = {nodesToArchive: []};
if (payload.nodes)
{
array.forEach(payload.nodes, function(node) {
config.nodesToArchive.push({"nodeRef": node.nodeRef});
});
}
var url ="http://localhost:8080/alfresco/s/com/test/export/documents";
var headers = {
"Content-Type": "application/json"
};
this.serviceXhr({
url: url,
headers: headers,
method: "POST",
data: {
"nodes": config.nodesToArchive
},
callbackScope: this,
successCallback: this.onSuccess,
failureCallback: this.onFailure
});
},
onSuccess:
function facetedsearch_DocumentService_onSuccess(response, originalRequestConfig) {
var msg = "Items are added successfully.";
this.alfLog("log", msg, response, originalRequestConfig);
Alfresco.util.PopupManager.displayMessage({ title: "Info", text: msg});
},
onFailure:
function facetedsearch_DocumentService_onFailure(response, originalRequestConfig) {
var msg = "Something went wrong.";
this.alfLog("log", msg, response, originalRequestConfig);
Alfresco.util.PopupManager.displayMessage({ title: "Info", text: msg});
}
});
});
Solved! Go to Solution.
It's always good to look at existing code of the library you are using. It could provide examples of how to call a backend web script.
It's always good to look at existing code of the library you are using. It could provide examples of how to call a backend web script.
Thank you Axel once more. I've solved it.
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.