Share (5.2) Controller JS : Call Alfresco REST API

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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
Highlighted
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

2 Replies
Highlighted
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.

Software Engineer in Alfresco Search Team.
Highlighted
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