Share (5.2) Controller JS : Call Alfresco REST API

cancel
Showing results for 
Search instead for 
Did you mean: 
gawel
Active Member II

Share (5.2) Controller JS : Call Alfresco REST API

Jump to solution

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 Solution

Accepted Solutions
gawel
Active Member II

Re: Share (5.2) Controller JS : Call Alfresco REST API

Jump to solution

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 solution in original post

3 Replies
angelborroy
Alfresco Employee

Re: Share (5.2) Controller JS : Call Alfresco REST API

Jump to solution

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
Active Member II

Re: Share (5.2) Controller JS : Call Alfresco REST API

Jump to solution

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);

Santiago-Florez
Member II

Re: Share (5.2) Controller JS : Call Alfresco REST API

Jump to solution
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.