Blogs

    List the blogs of a site

    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/blogs
      • 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 blogs; each object has the following properties:

    • id - the blog's ID (numeric)
    • siteId - the site's ID (numeric)
    • roleId - the ID of the user role assigned to the blog (numeric)
    • templateId - the ID of the template assigned to this blog (numeric)
    • blogName - the blog's name (string)
    • blogDescription - the blog's description (string)
    • title - the blog's title (string)
    • allowRSS - whether this blog is syndicated via a RSS feed or not (boolean)
    • rssChannelId - the RSS feed's ID (numeric)
    • lastPostDate - the date of the newest post (dateTime)
    • postCount - the total number of posts (numeric)
    • weight - the blog's weight (numeric)
    • releaseDate - the blog's release date (dateTime)
    • expiryDate - the blog's expiry date (dateTime)
    • createDate - the blog's create date (dateTime)
    • lastUpdateDate - the blog's last update date (dateTime)
    • enabled - whether the blog is enabled or not (boolean)
    • disableComments - whether site visitor comments are allowed or not (boolean)
    • slug - the blog's slug (string)
    • blogUrl - the blog's friendly URL (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 request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/blogs",
        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": 4405,
          "siteId": 246884,
          "roleId": 10000,
          "templateId": 613934,
          "blogName": "Blog",
          "blogDescription": "Welcome to my first blog",
          "title": "My first blog",
          "allowRSS": true,
          "rssChannelId": 5482,
          "lastPostDate": "2011-05-30T07:17:34.823",
          "postCount": 2,
          "weight": 20,
          "releaseDate": "2014-12-07T23:00:00",
          "expiryDate": "9998-12-31T15:00:00",
          "createDate": "2011-09-20T16:04:56.87",
          "lastUpdateDate": "2014-12-11T14:10:51.25",
          "enabled": true,
          "disableComments": false,
          "slug": "blog",
          "blogUrl": "/blog"
        }
      ],
      "totalItemsCount": 1,
      "skip": 0,
      "limit": 10
    }

    Get a blog's details

    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/blogs/[blog_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    Displays the details for the blog as a JSON object

    • id - the blog's ID (numeric)
    • siteId - the site's ID (numeric)
    • roleId - the ID of the user role assigned to the blog (numeric)
    • templateId - the ID of the template assigned to this blog (numeric)
    • blogName - the blog's name (string)
    • blogDescription - the blog's description (string)
    • title - the blog's title (string)
    • allowRSS - whether this blog is syndicated via a RSS feed or not (boolean)
    • rssChannelId - the RSS feed's ID (numeric)
    • lastPostDate - the date of the newest post (dateTime)
    • postCount - the total number of posts (numeric)
    • weight - the blog's weight (numeric)
    • releaseDate - the blog's release date (dateTime)
    • expiryDate - the blog's expiry date (dateTime)
    • createDate - the blog's create date (dateTime)
    • lastUpdateDate - the blog's last update date (dateTime)
    • enabled - whether the blog is enabled or not (boolean)
    • disableComments - whether site visitor comments are allowed or not (boolean)
    • slug - the blog's slug (string)
    • blogUrl - the blog's friendly URL (string)

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/blogs/4405",
        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": 4405,
      "siteId": 246884,
      "roleId": 10000,
      "templateId": 613934,
      "blogName": "Blog",
      "blogDescription": "Welcome to my first blog",
      "title": "My first blog",
      "allowRSS": true,
      "rssChannelId": 5482,
      "lastPostDate": "2011-05-30T07:17:34.823",
      "postCount": 2,
      "weight": 20,
      "releaseDate": "2014-12-07T23:00:00",
      "expiryDate": "9998-12-31T15:00:00",
      "createDate": "2011-09-20T16:04:56.87",
      "lastUpdateDate": "2014-12-11T14:10:51.25",
      "enabled": true,
      "disableComments": false,
      "slug": "blog",
      "blogUrl": "/blog"
    }

    Create a blog

    Request

    • Method: POST
    • 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/blogs/
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • roleId - the ID of the user role assigned to the blog (numeric)
    • templateId - the ID of the template assigned to this blog (numeric)
    • blogName - the blog's name (string)
    • blogDescription - the blog's description (string)
    • title - the blog's title (string)
    • allowRSS - whether this blog is syndicated via a RSS feed or not (boolean)
    • rssChannelId - the RSS feed's ID (numeric)
    • lastPostDate - the date of the newest post (dateTime)
    • postCount - the total number of posts (numeric)
    • weight - the blog's weight (numeric)
    • releaseDate - the blog's release date (dateTime)
    • expiryDate - the blog's expiry date (dateTime)
    • createDate - the blog's create date (dateTime)
    • lastUpdateDate - the blog's last update date (dateTime)
    • enabled - whether the blog is enabled or not (boolean)
    • disableComments - whether site visitor comments are allowed or not (boolean)
    • slug - the blog's slug (string)
    • blogUrl - the blog's friendly URL (string)

    Response

    Returns an empty body if successful or a detailed error message.

    Accepts and returns JSON as Content-Type.

    Response:

    HTTP/1.1 201 CREATED
    Location: /webresources/api/v3/sites/current/customers
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/blogs",
        type: "POST",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        processData: false,
        data: JSON.stringify({
            "blogName": "API created blog"
        })
    });
    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 a blog

    Request

    • Method:PUT
    • 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/blogs/[blog_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • roleId - the ID of the user role assigned to the blog (numeric)
    • templateId - the ID of the template assigned to this blog (numeric)
    • blogName - the blog's name (string)
    • blogDescription - the blog's description (string)
    • title - the blog's title (string)
    • allowRSS - whether this blog is syndicated via a RSS feed or not (boolean)
    • rssChannelId - the RSS feed's ID (numeric)
    • lastPostDate - the date of the newest post (dateTime)
    • postCount - the total number of posts (numeric)
    • weight - the blog's weight (numeric)
    • releaseDate - the blog's release date (dateTime)
    • expiryDate - the blog's expiry date (dateTime)
    • createDate - the blog's create date (dateTime)
    • lastUpdateDate - the blog's last update date (dateTime)
    • enabled - whether the blog is enabled or not (boolean)
    • disableComments - whether site visitor comments are allowed or not (boolean)
    • slug - the blog's slug (string)
    • blogUrl - the blog's friendly URL (string)

    Response

    Returns an empty body if successful or a detailed error message.

    Accepts and returns JSON as Content-Type.


    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/blogs/18029",
        type: "PUT",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        processData: false,
    	data: JSON.stringify({
            "blogDescription": "This blog was created using API",
            "expiryDate": "1-Jan-2016"
        })
    });
    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 blogs

    Request

    • Method: DELETE
    • 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/blogs/[blog_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    Returns an empty body if successful or a detailed error message.


    Request:

    DELETE /webresources/api/v3/sites/current/blogs/18029 HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/blogs/[blog_ID]
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/blogs/[blogid]",
    type: "DELETE",
    connection: "keep-alive",
    contentType: "application/json",
    headers: {
    "Authorization": $.cookie('access_token')
    }
    }); request.done(function (msg) {
    $('.output pre').html(JSON.stringify(msg, null, 2));
    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); })