Blog posts

    List the blog posts of a site (across all blogs)

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

    • id - the blogpost's ID (numeric)
    • siteId - the site's ID (numeric)
    • blogId - the blog's ID (numeric)
    • postTitle - the post's title (string)
    • postFeaturedImage - the post's featured image URL (string)
    • postBody - the post's content (string)
    • createBy - the ID of the user who created the post (numeric)
    • releaseDate - the post's release date (dateTime)
    • createDate - the post's create date (dateTime)
    • lastUpdateDate - the date of the latest update (dateTime)
    • enabled - whether the post is enabled or not (boolean)
    • deleted - whether the post was deleted or not (boolean)
    • disableComments - whether site visitor comments are allowed or not (boolean)
    • slug - the post's slug (string)
    • postUrl - the post's friendly URL (string)
    • metaBlogPostTitle - the post's meta title (string)
    • metaBlogPostDescription - the post's 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 request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/blogposts",
        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": 303870,
          "siteId": 246884,
          "blogId": 4405,
          "postTitle": "Some philosophical questions...",
          "postFeaturedImage": "/img/mock.jpg",
          "postBody": "CONTENT HERE",
          "createBy": 1087314,
          "releaseDate": "2014-12-09T23:00:00",
          "createDate": "2011-09-20T16:04:56.887",
          "lastUpdateDate": "2014-12-11T14:08:19.76",
          "enabled": true,
          "deleted": false,
          "reIndex": false,
          "disableComments": false,
          "slug": "some-philosophical-questions",
          "postUrl": "/blog/some-philosophical-questions",
          "metaBlogPostTitle": "Some philosophical questions...",
          "metaBlogPostDescription": "Food for thought"
        },
        {
          "id": 303871,
          "siteId": 246884,
          "blogId": 4405,
          "postTitle": "Welcome to my Blog!",
          "postFeaturedImage": null,
          "postBody": "CONTENT HERE",
          "createBy": 1087314,
          "releaseDate": "2014-12-07T23:00:00",
          "createDate": "2011-09-20T16:04:56.923",
          "lastUpdateDate": "2014-12-11T14:08:14.213",
          "enabled": true,
          "deleted": false,
          "reIndex": false,
          "disableComments": false,
          "slug": "welcome-to-my-blog",
          "postUrl": "/blog/welcome-to-my-blog",
          "metaBlogPostTitle": "",
          "metaBlogPostDescription": ""
        }
      ],
      "totalItemsCount": 2,
      "skip": 0,
      "limit": 10
    }

    Get a blog post'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/blogposts/[blogpost_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 post as a JSON object

    • id - the blogpost's ID (numeric)
    • siteId - the site's ID (numeric)
    • blogId - the blog's ID (numeric)
    • postTitle - the post's title (string)
    • postFeaturedImage - the post's featured image URL (string)
    • postBody - the post's content (string)
    • createBy - the ID of the user who created the post (numeric)
    • releaseDate - the post's release date (dateTime)
    • createDate - the post's create date (dateTime)
    • lastUpdateDate - the date of the latest update (dateTime)
    • enabled - whether the post is enabled or not (boolean)
    • deleted - whether the post was deleted or not (boolean)
    • disableComments - whether site visitor comments are allowed or not (boolean)
    • slug - the post's slug (string)
    • postUrl - the post's friendly URL (string)
    • metaBlogPostTitle - the post's meta title (string)
    • metaBlogPostDescription - the post's meta description (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/blogposts/303870",
        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": 303870,
      "siteId": 246884,
      "blogId": 4405,
      "postTitle": "Some philosophical questions...",
      "postFeaturedImage": "/img/mock.jpg",
      "postBody": "CONTENT HERE ",
      "createBy": 1087314,
      "releaseDate": "2014-12-09T23:00:00",
      "createDate": "2011-09-20T16:04:56.887",
      "lastUpdateDate": "2014-12-11T14:08:19.76",
      "enabled": true,
      "deleted": false,
      "reIndex": false,
      "disableComments": false,
      "slug": "some-philosophical-questions",
      "postUrl": "/blog/some-philosophical-questions",
      "metaBlogPostTitle": "Some philosophical questions...",
      "metaBlogPostDescription": "Food for thought"
    }

    Create a blog post

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

    Parameters

    • blogId - the blog's ID (numeric)
    • postTitle - the post's title (string)
    • postFeaturedImage - the post's featured image URL (string)
    • postBody - the post's content (string)
    • createBy - the ID of the user who created the post (numeric)
    • releaseDate - the post's release date (dateTime)
    • createDate - the post's create date (dateTime)
    • lastUpdateDate - the date of the latest update (dateTime)
    • enabled - whether the post is enabled or not (boolean)
    • deleted - whether the post was deleted or not (boolean)
    • disableComments - whether site visitor comments are allowed or not (boolean)
    • slug - the post's slug (string)
    • postUrl - the post's friendly URL (string)
    • metaBlogPostTitle - the post's meta title (string)
    • metaBlogPostDescription - the post's meta description (string)

    Response:

    HTTP/1.1 201 CREATED
    Location: /webresources/api/v3/sites/current/blogposts
    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/blogposts",
        type: "POST",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        processData: false,
        data: JSON.stringify({
            "blogId": 18029,
            "postTitle": "First post",
            "createBy": 468869
        })
    });
    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);
    })

    Response

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

    Accepts and returns JSON as Content-Type.


    Edit a blog post

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

    Parameters

    • blogId - the blog's ID (numeric)
    • postTitle - the post's title (string)
    • postFeaturedImage - the post's featured image URL (string)
    • postBody - the post's content (string)
    • createBy - the ID of the user who created the post (numeric)
    • releaseDate - the post's release date (dateTime)
    • createDate - the post's create date (dateTime)
    • lastUpdateDate - the date of the latest update (dateTime)
    • enabled - whether the post is enabled or not (boolean)
    • deleted - whether the post was deleted or not (boolean)
    • disableComments - whether site visitor comments are allowed or not (boolean)
    • slug - the post's slug (string)
    • postUrl - the post's friendly URL (string)
    • metaBlogPostTitle - the post's meta title (string)
    • metaBlogPostDescription - the post's meta description (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/blogposts/1383385",
        type: "PUT",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        processData: false,
        data: JSON.stringify({
            "blogId": 18029,
            "postTitle": "First post - edited",
            "createBy": 468869
        })
    });
    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 blog post

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

    Request:

    DELETE /webresources/api/v3/sites/current/blogposts/1383385 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/blogposts/[blogpost_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/blogposts/[id]",
        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);
    })

    Response

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