Motez
Motez

Reputation: 91

Create new site with REST API

I want to create a new site in Alfresco through the REST API first i tried with the url /alfresco/service/api/sites the site was created but i could not open it. I read the method description and it says

Note: this method only creates a site at the repository level, it does not create a fully functional site. It should be considered for internal use only at the moment. Currently, creating a site programmatically needs to be done in the Share context, using the create-site module. Further information can be found at the address http://your_domain:8080/share/page/index/uri/modules/create-site.post within your Alfresco installation.

I tried to go to the suggested url but it gives 404 ! Any help or suggestions ?

Upvotes: 1

Views: 570

Answers (1)

Gagravarr
Gagravarr

Reputation: 48326

Note - the links/references in this answer all assume you've got the Alfresco Share application installed and available at http://localhost:8081/share/ - tweak as needed for your machine

When wanting to understand or discover webscripts, the first place you want to head to is http://localhost:8081/share/service/index - the Share WebScripts home. (The Alfresco repo tier has an equivalent one too, available at a similar URL).

When there, you'll see all of the Share-side WebScripts listed, of which there are a lot. You could search through that list for create-site. However, you can restrict the webscript listing by URL or by module. For the Create Site webscripts, the URL to see just those is http://localhost:8081/share/page/index/uri/modules/create-site

Head there, and you'll discover there are two create site related webscripts, a get and a post. As you've discovered already, the one you'll want is the POST webscript. Click on that to get the details, at http://localhost:8081/share/page/script/org/alfresco/modules/create-site.post - that's the latest (Alfresco 5.x) URL for the thing you've been directed to in your question. If your Share installation is at a different URL, then once you've navigated from the Share webscripts home, you'll get the specific one for your machine

Finally, you'd need to post the required JSON to that webscript's URI, which is given in the webscript listing, eg http://localhost:8081/share/page/modules/create-site . Easiest way to see exactly what JSON you need is to use firebug / developer tools / etc to see the handful of keys/values that Share sends when you create one through the UI.

Upvotes: 2

Related Questions