AnsweredAssumed Answered

create a site in alfresco

Question asked by yosrioh on Mar 30, 2016
Latest reply on Apr 18, 2016 by yosrioh
i am trying to create a site in alfresco by using WEB SCRIPT
" POst http://localhost:8080/share/service/modules/create-site"
i tested this java code that generates no errors and seems to execute fine but when i check in the alfresco dashboard the site is not created

public class TestShareCreateSitePost {

   public static void main(String[] args) throws Exception {

   private static String createSite() {
      try {
         DefaultHttpClient client = new DefaultHttpClient();
         HttpPost post = new HttpPost(
         List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
         nameValuePairs.add(new BasicNameValuePair("username", "admin"));
         nameValuePairs.add(new BasicNameValuePair("password", "admin"));
         post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
         CookieStore cookieStore = client.getCookieStore();
         client = new DefaultHttpClient();
         post = new HttpPost(
         post.setHeader("Content-Type", "application/json");
         post.setEntity(new StringEntity(createSiteParameters(
               "JavaTest-001", "Sito di test by JAVA", "JavaTest-001"),
         ResponseHandler<String> responseHandler = new BasicResponseHandler();
         String response = client.execute(post, responseHandler);
         return response;
      } catch (Exception e) {
      return "Error!";

   private static String createSiteParameters(String title,
         String description, String shortName) {
      String site = "{\"visibility\":\"PUBLIC\", "
            + "\"sitePreset\":\"site-dashboard\", " + "\"title\":\""
            + title + "\", " + "\"description\":\"" + description + "\", "
            + "\"shortName\":\"" + shortName + "\"}";
      return site;

i have also made the modification to disable the CSRF filter but it didn't work also
can someone tell me what im i missing ?