cancel
Showing results for 
Search instead for 
Did you mean: 

How to create site via REST API

jamalissimo
Champ in-the-making
Champ in-the-making
Hello guys,

I am trying to create a site via REST API and I am not able to create it because of 401 Unauthorized - error.loggedOut.
Is here somebody who can tell me how to create site?

Here is my way:

1. Log in to get a ticket
POST /alfresco/service/api/login HTTP/1.1Host: localhost:8080Content-Type: application/jsonAccept: application/jsonCache-Control: no-cachePostman-Token: f6d43cb0-7788-9d22-f17e-635ea8d49e6e{"username":"admin","password":"enboxadmin"}‍‍‍‍‍‍‍‍‍‍‍

RESULT{  "data": {    "ticket": "TICKET_253acd23d357b2405c446bf4ce662d0cc568a480"  }}‍‍‍‍‍‍‍‍


2.Create site
POST /share/service/modules/create-site?alf_ticket=TICKET_253acd23d357b2405c446bf4ce662d0cc568a480 HTTP/1.1Host: localhost:8080Content-Type: application/jsonAccept: application/jsonCache-Control: no-cachePostman-Token: 77ab4770-730c-cacf-de98-6d1b80d74466{    "sitePreset": "site-dashboard",    "shortName": "Sandbox",    "title": "Sandbox site",    "description": "This is a sample site.",    "visibility": "PRIVATE"  }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

RESULT{  "status": {    "code": 401,    "name": "Unauthorized",    "description": "The request requires HTTP authentication."  },  "message": "error.loggedOut",  "exception": "",  "callstack": [],  "server": "Spring WebScripts - v5.0.0 (Release) schema 1 000",  "time": "8.9.2015 5:06:04"}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Is this the correct procedure how to create site in share?

Thanks

-Roman
1 REPLY 1

gspyrou
Champ in-the-making
Champ in-the-making
You need to POST to /alfresco/s/api/sites (see http://docs.alfresco.com/5.0/references/RESTful-SiteSitesPost.html for more details).

George.