Pages

    List available webpages and get their attributes

    This section details the endpoints you can use to list the webpages created on a particular site and get their properties.

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/pages
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    An array of the first 10 web pages; each object has the following properties:

    • id - the page's ID (number)
    • siteId - the ID of the site the page is on (number)
    • workflowId - the ID of the workflow assigned (-1 of the page does not have a workflow assigned) (number)
    • roleId - the ID of the role responsible (-1 if not applicable) (number)
    • templateId - the ID of the template (-1 if no template is applied or 0 to use the default template) (number)
    • parentId - the ID of the parent page (-1 if no page is applied or 0 to use the default template) (number)
    • livePageId - only applicable if the "displayable" parameter is "true" (meaning this is a draft page). The "livePageId" is the ID of the live page. (number)
    • pageUrl - the page's url (string)
    • name - the page's name (string)
    • displayFileName - the page's display name (string)
    • size - the page's size (number)
    • enabled - whether the page is enabled or not (boolean)
    • startPage - whether the page is set as start page(boolean)
    • createDate - the creation date of the page (dateTime)
    • lastUpdateDate - the last update date of the page (dateTime)
    • releaseDate - the release date of the page (dateTime)
    • expiryDate - the expiry date of the page (dateTime)
    • displayable - whether the page is live or it is a draft page (boolean)
    • excludeFromSearch - whether to exclude the page from the site search (boolean)
    • content - the content of the page HTML encoded (string)
    • redirect301 - the URL this page should 301 redirect to (string)
    • title - the page's title (string)
    • seoMetadataDescription - the page's SEO meta description (string)

    You can output additional fields to those listed above as default, see the API v3 Discovery APP for additional details.

    Accepts and returns JSON as Content-Type.


    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/pages",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Sample response

    
    {
      "items": [
        {
         "id":9017917,
         "siteId":2163596,
         "workflowId":-1,
         "roleId":-1,
         "templateId":0,
         "parentId":-1,
         "livePageId":null,
         "pageUrl":"/about.html",
         "name":"About Us",
         "displayFileName":"about.html",
         "size":5281,
         "enabled":true,
         "startPage":false,
         "createDate":"2015-07-14T01:22:17.67",
         "lastUpdateDate":"2015-07-31T11:49:02.1",
         "releaseDate":"2015-07-31T11:49:02.1",
         "expiryDate":"9998-12-31T15:00:00",
         "displayable":true,
         "excludeFromSearch":false,
         "content":"Content here",
         "redirect301":"",
         "title":"About Us",
         "seoMetadataDescription":"Sample description"
        },
        {
         "id":9017918,
         "siteId":2163596,
         "workflowId":-1,
         "roleId":-1,
         "templateId":0,
         "parentId":-1,
         "livePageId":null,
         "pageUrl":"/contact",
         "name":"Contact",
         "displayFileName":"contact.html",
         "size":2810,
         "enabled":true,
         "startPage":false,
         "createDate":"2015-07-14T01:22:17.67",
         "lastUpdateDate":"2015-08-06T13:21:41.373",
         "releaseDate":"2015-08-03T00:00:00",
         "expiryDate":"9998-12-31T15:00:00",
         "displayable":true,
         "excludeFromSearch":false,
         "content": "Page2 content",
         "redirect301": "",
         "title": "Contact Us",
         "seoMetadataDescription": "Sample metadata"
        }
    ],
    "totalItemsCount": 2,    
    "skip": 0,    
    "limit": 10
    }
          

    Get a webpage's attributes

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/pages/[page_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    Returns the properties below for a single page:

    • id - the page's ID (number)
    • siteId - the ID of the site the page is on (number)
    • workflowId - the ID of the workflow assigned (-1 of the page does not have a workflow assigned) (number)
    • roleId - the ID of the role responsible (-1 if not applicable) (number)
    • templateId - the ID of the template (-1 if no template is applied or 0 to use the default template) (number)
    • parentId - the ID of the parent page (-1 if no page is applied or 0 to use the default template) (number)
    • livePageId - only applicable if the "displayable" parameter is "true" (meaning this is a draft page). The "livePageId" is the ID of the live page. (number)
    • pageUrl - the page's url (string)
    • name - the page's name (string)
    • displayFileName - the page's display name (string)
    • size - the page's size (number)
    • enabled - whether the page is enabled or not (boolean)
    • startPage - whether the page is set as start page(boolean)
    • createDate - the creation date of the page (dateTime)
    • lastUpdateDate - the last update date of the page (dateTime)
    • releaseDate - the release date of the page (dateTime)
    • expiryDate - the expiry date of the page (dateTime)
    • displayable - whether the page is live or it is a draft page (boolean)
    • excludeFromSearch - whether to exclude the page from the site search (boolean)
    • content - the content of the page HTML encoded (string)
    • redirect301 - the URL this page should 301 redirect to (string)
    • title - the page's title (string)
    • seoMetadataDescription - the page's SEO meta description (string)

    Accepts and returns JSON as Content-Type.


    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/pages/9017917",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Sample response

    {
         "id":9017917,
         "siteId":2163596,
         "workflowId":-1,
         "roleId":-1,
         "templateId":0,
         "parentId":-1,
         "livePageId":null,
         "pageUrl":"/about.html",
         "name":"About Us",
         "displayFileName":"about.html",
         "size":5281,
         "enabled":true,
         "startPage":false,
         "createDate":"2015-07-14T01:22:17.67",
         "lastUpdateDate":"2015-07-31T11:49:02.1",
         "releaseDate":"2015-07-31T11:49:02.1",
         "expiryDate":"9998-12-31T15:00:00",
         "displayable":true,
         "excludeFromSearch":false,
         "content":"Content here",
         "redirect301":"",
         "title":"About Us",
         "seoMetadataDescription":"Sample description"
    }

    Create new live and draft pages

    Request

    • Method: POST
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/pages
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The response should be "201 created" if the page was successfully created.

    Here are the parameters you can use when creating a page:

    • siteId - the ID of the site the page is on (number)
    • workflowId - the ID of the workflow assigned (-1 of the page does not have a workflow assigned) (number)
    • roleId - the ID of the role responsible (-1 if not applicable) (number)
    • templateId - the ID of the template (-1 if no template is applied or 0 to use the default template) (number)
    • parentId - the ID of the parent page (-1 if no page is applied or 0 to use the default template) (number)
    • livePageId - only applicable if the "displayable" parameter is "true" (meaning this is a draft page). The "livePageId" is the ID of the live page. (number)
    • pageUrl - the page's url (string)
    • name - the page's name (string)
    • displayFileName - the page's display name (string)
    • size - the page's size (number)
    • enabled - whether the page is enabled or not (boolean)
    • startPage - whether the page is set as start page(boolean)
    • createDate - the creation date of the page (dateTime)
    • lastUpdateDate - the last update date of the page (dateTime)
    • releaseDate - the release date of the page (dateTime)
    • expiryDate - the expiry date of the page (dateTime)
    • displayable - whether the page is live or it is a draft page (boolean)
    • excludeFromSearch - whether to exclude the page from the site search (boolean)
    • content - the content of the page HTML encoded (string)
    • redirect301 - the URL this page should 301 redirect to (string)
    • title - the page's title (string)
    • seoMetadataDescription - the page's SEO meta description (string)

    Sample code

    In the example below we create a brand new Live page:

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
      url: "/webresources/api/v3/sites/current/pages",
      processData: false,
      data: JSON.stringify({
        "name": "About-page",
        "pageUrl": "/about-page",
        "displayable": false,
        "displayFileName": "About",
        "content": "<h1>This is my About page</h1><p>Some content here</p>",
        "templateId": "0"
      }),
      type: "POST",    
        contentType: "application/json",
      headers: {
        "Authorization": $.cookie('access_token')
      }
    });
    request.done(function(msg) {
      console.log(msg);
    })
    request.fail(function(jqXHR) {
      console.log("Request failed.");
      console.log("Error code: " + jqXHR.status);
      console.log("Error text: " + jqXHR.statusText);
      console.log("Response text: " + jqXHR.responseText);
    })

    Create a Draft page for the page above

    The draft will need to have a corresponding Live page (it cannot exist as a stand alone draft). You will notice the call is almost identical but for a single parameter. livePageId serves two purposes - it marks this page as draft and specifies what page this is the draft for:

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
      url: "/webresources/api/v3/sites/current/pages",
      processData: false,
      data: JSON.stringify({
        "name": "About-page2",
        "pageUrl": "/about-page2",
        "displayable": true,
    	  "livePageId": 13752869,
        "deleted": false,
        "displayFileName": "About - new",
        "content": "<h1>This is my About page</h1><p>Some newer content here</p>",
        "templateId": "0"
      }),
      type: "POST",    
      contentType: "application/json",
      
      headers: {
        "Authorization": $.cookie('access_token')
      }
    });
    request.done(function(msg) {
      console.log(msg);
    })
    request.fail(function(jqXHR) {
      console.log("Request failed.");
      console.log("Error code: " + jqXHR.status);
      console.log("Error text: " + jqXHR.statusText);
      console.log("Response text: " + jqXHR.responseText);
    })

    In this example below we will take live (Publish) the draft page created above live. This means its content of the draft page will replace the content of the page with the ID 13752869 (the original About page).

    Before we run the call that actually publishes the page there is an extra step we need to take into account. We know the ID of the live page, we specified it when creating the draft. What is the ID of the draft page itself?

    Note: the live and draft pages are treated as sepparated entities, each of them is a stand-alone page, with a different ID and optionally even a different URL.

    Get the ID of the draft page

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
      url: '/webresources/api/v3/sites/current/pages?where={"livePageId":13752911}',
      type: "GET",    
      contentType: "application/json",
      
      headers: {
        "Authorization": $.cookie('access_token')
      }
    });
    request.done(function(msg) {
    //this logs the ID of the draft page  
    console.log(msg.items[0].id);
    })
    request.fail(function(jqXHR) {
      console.log("Request failed.");
      console.log("Error code: " + jqXHR.status);
      console.log("Error text: " + jqXHR.statusText);
      console.log("Response text: " + jqXHR.responseText);
    })

    Taking a draft page live (publishing it)

    Now that we know the ID of the draft page (13752930) let's take it live:

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
      url: "/webresources/api/v3/sites/current/pages/13752930?publish=true",
      type: "PUT",    
      contentType: "application/json",
      
      headers: {
        "Authorization": $.cookie('access_token')
      }
    });
    request.done(function(msg) {
      console.log(msg);
    })
    request.fail(function(jqXHR) {
      console.log("Request failed.");
      console.log("Error code: " + jqXHR.status);
      console.log("Error text: " + jqXHR.statusText);
      console.log("Response text: " + jqXHR.responseText);
    })

    Edit an existing page

    Request

    • Method: GET
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/pages
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The response should be "204 no content" if the secure zone was successfully modified.

    Here are the parameters you can use when updating a page:

    • siteId - the ID of the site the page is on
    • url - the page's URL
    • name - the page's NAME
    • deleted - whether the page is deleted or not
    • categoryId - the ID of the workflow assigned (-1 of the page does not have a workflow assigned)
    • roleId - the ID of the role responsible (-1 if not applicable)
    • templateId - the ID of the template (-1 if no template is applied or 0 to use the default template)
    • displayFileName - the page's display name
    • size - the page's size
    • enabled - whether the page is enabled or not
    • startPage - whether the page is set as start page
    • releaseDate - the release date of the page
    • expiryDate - the expiry date of the page
    • displayable - whether the page is live or it is a draft page
    • excludeFromSearch - whether to exclude the page from the site search
    • livePageId - only applicable if the "displayable" parameter is "true" (meaning this is a draft page). The "livePageId" is the ID of the live page.
    • content - the content of the page HTML encoded
    • redirect301 - the URL this page should 301 redirect to
    • title - the page's title
    • seoMetadataDescription - the page's SEO meta description

    Sample code

    In this example let's remove the template for the page with the ID 4518294. To do this we will assign the template with the ID -1:

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
      url: "/webresources/api/v3/sites/current/pages/4518294",
      processData: false,
      data: JSON.stringify({
      	"name": "Card - modified",
     	"templateId" : "-1"
        }),
      type: "PUT",    
      contentType: "application/json",
      
      headers: {
         "Authorization": $.cookie('access_token')
      }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Delete a webpage

    This section details the endpoints you can use to delete a webpage.

    Request

    • Method: DELETE
    • Version: v3
    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/pages/[page_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The response should be "204 no content" if the page was successfully deleted.


    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/pages/2567169",
        type: "DELETE",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })