AnsweredAssumed Answered

How to create site via REST API

Question asked by jamalissimo on Sep 8, 2015
Latest reply on Sep 16, 2015 by gspyrou
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.1
Host: localhost:8080
Content-Type: application/json
Accept: application/json
Cache-Control: no-cache
Postman-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.1
Host: localhost:8080
Content-Type: application/json
Accept: application/json
Cache-Control: no-cache
Postman-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

Outcomes