HTTP request from alfresco javascrit file

Showing results for 
Search instead for 
Did you mean: 
Member II

HTTP request from alfresco javascrit file

I am new in alfresco and I create a rule that execute a javascript file when a file arrives in a directory (My javascript it inside data dictionnary script file). However, this javascript script must send a http get request to a remote server but I can not use the alfresco remote. Can you suggest a solution? Thank you

My javascript code:

function main() {
    var name =;
    var username = "";
    var msgContent = "";
    var siteName = document.siteShortName;
    var firstName =;
    var lastName =;

    if (siteName == null) {
        if (logger.isLoggingEnabled())

    if (firstName != null) {
        username = username + firstName + " ";
    if (lastName != null) {
        username = username + lastName;
    msgContent = username + " a ajouté un nouvel élément de contenu " + name + " au site " + siteName;

    if (logger.isLoggingEnabled()) {
    var connector = remote.connect("gedrepportremote");
    var result = connector.get("/api/sendSMS?siteName=" + encodeURIComponent(siteName) + "&msgContent="+encodeURIComponent(msgContent));
    if (result.status == 200) {
        return JSON.parse(result);
    } else if (result.status == 403) {
    } else {
        return null;


I have this error : "remote is not defined". I tried this HTTP Request from WebScript in Alfresco but it doesn't work for me.

1 Reply
Senior Member II

Re: HTTP request from alfresco javascrit file

The "remote" object is not availabe by default when using rule scripts. See Axel Faust‌ answer in Call a repository webscript from a rule script 
He also describes how to enable the "remote" root object...