cancel
Showing results for 
Search instead for 
Did you mean: 

Share (5.2) Controller JS : Call Alfresco REST API

gawel
Confirmed Champ
Confirmed Champ

Hi,

For call Alfresco Webscript from Share on a controller js we used this code :

var conn = remote.connect("alfresco");

var repoResponse = conn.post("/api/sites", clientRequest, "application/json");

And this work.

So, How call Alfresco REST API on this same context?

See API information : Alfresco Content Services REST API Explorer 

var conn = remote.connect("alfresco");
var repoResponse = conn.get("/sites");

Doesn't work...

thx

1 ACCEPTED ANSWER

gawel
Confirmed Champ
Confirmed Champ

Hi,

This work fine (Resolve) for Alfresco V5.2 :

                var conn = remote.connect("alfresco-api");
                var repoResponse = conn.get("/-default-/public/alfresco/versions/1/sites");
                logger.warn(repoResponse.status);

View answer in original post

3 REPLIES 3

angelborroy
Community Manager Community Manager
Community Manager

You cannot use this "remote.connect" for the new REST API, as is taking a root including an "extra s":

https://github.com/Alfresco/alfresco-sdk-samples/blob/master/samples/alfresco-rm-custom/share-amp/sr...

Probably you can add a new connector "alfresco-new" with "endpoint-url" value at "${alfresco.repo.url}/api/-default-/public/alfresco/versions/1" in "share-config-custom.xml" and then you could use remote.connect("alfresco-new"). Anyway I didn't tested this.

Hyland Developer Evangelist

gawel
Confirmed Champ
Confirmed Champ

Hi,

This work fine (Resolve) for Alfresco V5.2 :

                var conn = remote.connect("alfresco-api");
                var repoResponse = conn.get("/-default-/public/alfresco/versions/1/sites");
                logger.warn(repoResponse.status);

Hello gawel I want to know what you configured in your alfresco to use remote object, because when I try to use it I get this error. 500 Internal Error Stacktrace-Details: org.springframework.extensions.webscripts.WebScriptException: 11150002 Wrapped Exception (with status template): 11150025 Failed to execute script 'Javascript Console Script': 11150024 ReferenceError: "remote" is not defined.