<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to create a site with REST API from javascript? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-create-a-site-with-rest-api-from-javascript/m-p/23692#M10340</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is what am trying to do ,top create a site from REST API in javascript.&lt;/P&gt;&lt;P&gt;(Alfresco community edition 201707)&lt;/P&gt;&lt;P&gt;function CreateSite(){&lt;BR /&gt; /*TEST API - START*/&lt;BR /&gt; var siteBodyCreate = {&lt;BR /&gt; "id": "NewTest",&lt;BR /&gt; "title": "NewTest",&lt;BR /&gt; "description": "NewTest",&lt;BR /&gt; "visibility": "PUBLIC"&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;$.ajax({&lt;BR /&gt; type: 'POST',&lt;BR /&gt; beforeSend: function(request) {&lt;BR /&gt; request.setRequestHeader("Authority", 'Basic YWRtaW46YWRtaW4=');&lt;BR /&gt; },&lt;BR /&gt; headers: {&lt;BR /&gt; 'Content-Type': 'application/json',&lt;BR /&gt; 'Accept':'application/json',&lt;BR /&gt; 'Authorization': 'Basic YWRtaW46YWRtaW4='&lt;BR /&gt; },&lt;BR /&gt; dataType: 'json',&lt;BR /&gt;&lt;SPAN&gt; url: '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/sites?skipConfiguration=false&amp;amp;skipAddToFavorites=false" rel="nofollow noopener noreferrer" target="_blank"&gt;http://127.0.0.1:8080/alfresco/api/-default-/public/alfresco/versions/1/sites?skipConfiguration=false&amp;amp;skipAddToFavorites=false&lt;/A&gt;&lt;SPAN&gt;',&lt;/SPAN&gt;&lt;BR /&gt; data:JSON.stringify({"entry" : siteBodyCreate}) ,&lt;BR /&gt; success: function(data) {&lt;BR /&gt; alert(data);&lt;BR /&gt; } ,&lt;BR /&gt; failure : function(data){&lt;BR /&gt; alert(data);&lt;BR /&gt; } &lt;BR /&gt; });&lt;BR /&gt; /*TEST API - END*/&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;i get the following error&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt; "error": {&lt;BR /&gt; "errorKey": "Could not read content from HTTP request body: Unrecognized field \"entry\" (Class org.alfresco.rest.api.model.Site), not marked as ignorable\n at [Source: java.io.BufferedReader@5ad545e1; line: 1, column: 11] (through reference chain: org.alfresco.rest.api.model.Site[\"entry\"])",&lt;BR /&gt; "statusCode": 400,&lt;BR /&gt; "briefSummary": "07300002 Could not read content from HTTP request body: Unrecognized field \"entry\" (Class org.alfresco.rest.api.model.Site), not marked as ignorable\n at [Source: java.io.BufferedReader@5ad545e1; line: 1, column: 11] (through reference chain: org.alfresco.rest.api.model.Site[\"entry\"])",&lt;BR /&gt; "stackTrace": "For security reasons the stack trace is no longer displayed, but the property is kept for previous versions",&lt;BR /&gt;&lt;SPAN&gt; "descriptionURL": "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://api-explorer.alfresco.com" rel="nofollow noopener noreferrer" target="_blank"&gt;https://api-explorer.alfresco.com&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the right approach?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Aug 2017 08:49:33 GMT</pubDate>
    <dc:creator>anandhan</dc:creator>
    <dc:date>2017-08-30T08:49:33Z</dc:date>
    <item>
      <title>How to create a site with REST API from javascript?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-create-a-site-with-rest-api-from-javascript/m-p/23692#M10340</link>
      <description>This is what am trying to do ,top create a site from REST API in javascript.(Alfresco community edition 201707)function CreateSite(){ /*TEST API - START*/ var siteBodyCreate = { "id": "NewTest", "title": "NewTest", "description": "NewTest", "visibility": "PUBLIC" };$.ajax({ type: 'POST', beforeSend:</description>
      <pubDate>Wed, 30 Aug 2017 08:49:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-create-a-site-with-rest-api-from-javascript/m-p/23692#M10340</guid>
      <dc:creator>anandhan</dc:creator>
      <dc:date>2017-08-30T08:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a site with REST API from javascript?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-create-a-site-with-rest-api-from-javascript/m-p/23693#M10341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check your&amp;nbsp;JSON payload. You do not need the top-level "entry" ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may&amp;nbsp;find it useful to sanity check&amp;nbsp;via "curl" or Postman (or your favourite HTTP/REST client) ?&amp;nbsp;You may also find it useful to take a look at&amp;nbsp;&lt;A href="https://community.alfresco.com/community/ecm/blog/2017/02/24/v1-rest-api-part-8-sites" rel="nofollow noopener noreferrer"&gt;https://community.alfresco.com/community/ecm/blog/2017/02/24/v1-rest-api-part-8-sites&lt;/A&gt;&amp;nbsp;or simply "Try it out !" via the API explorer to see an example payload&amp;nbsp;&lt;A class="link-titled" href="https://api-explorer.alfresco.com/api-explorer/#!/sites/createSite" title="https://api-explorer.alfresco.com/api-explorer/#!/sites/createSite" rel="nofollow noopener noreferrer"&gt;Alfresco Content Services REST API Explorer&lt;/A&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another option is to have a look at how it is done via the&amp;nbsp;Alfresco JS API "&lt;A href="https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/SitesApi.md#createSite" rel="nofollow noopener noreferrer"&gt;create site&lt;/A&gt;" or use that instead ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Aug 2017 11:05:08 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-create-a-site-with-rest-api-from-javascript/m-p/23693#M10341</guid>
      <dc:creator>janv</dc:creator>
      <dc:date>2017-08-30T11:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a site with REST API from javascript?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-create-a-site-with-rest-api-from-javascript/m-p/23694#M10342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hi Jan Vonkan&lt;SPAN style="background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #000000;"&gt;It was helpul.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; color: #000000;"&gt;But now i have end up with error saying "Can not get preferences for admin because there was an error pasing the JSON data"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Aug 2017 10:15:40 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-create-a-site-with-rest-api-from-javascript/m-p/23694#M10342</guid>
      <dc:creator>anandhan</dc:creator>
      <dc:date>2017-08-31T10:15:40Z</dc:date>
    </item>
  </channel>
</rss>

