Blogs and categories

List a blog's categories

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]/categories
    • 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 categories assigned to the blog; each object has the following properties:

  • id - the category's ID (numeric)
  • siteId - the site's ID (numeric)
  • parentId - the ID of the parent (numeric)
  • category - the category's name (string)
  • publicAccess - whether this category is visible in the site's front-end or not (boolean)
  • Default - whether this category is to be marked as default or not (boolean)
  • deleted - whether this category is enabled or not (boolean)

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/4405/categories",
    type: "GET",
    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); })

Sample response

{
  "items": [
    {
      "objectId": 18029,
      "categoryId": 14606,
      "objectType": 55,
      "displayable": 1,
      "siteId": 246884,
      "category": {
        "id": 14606,
        "siteId": 246884,
        "categoryTypeId": 42,
        "parentId": -1,
        "category": "Company",
        "publicAccess": true,
        "Default": false,
        "Deleted": false
      }
    },
    {
      "objectId": 18029,
      "categoryId": 14744,
      "objectType": 55,
      "displayable": 1,
      "siteId": 246884,
      "category": {
        "id": 14744,
        "siteId": 246884,
        "categoryTypeId": 42,
        "parentId": -1,
        "category": "Customers",
        "publicAccess": true,
        "Default": false,
        "Deleted": false
      }
    }
  ],
  "totalItemsCount": 2,
  "skip": 0,
  "limit": 10
}

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

Sample request

var access_token = BCAPI.Helper.Site.getAccessToken();

var request = $.ajax({
    url: "/webresources/api/v3/sites/current/blogs/18029/categories",
    type: "GET",
    connection: "keep-alive",    
    contentType: "application/json",
    headers: {
        "Authorization": $.cookie('access_token')
    },
    processData: false,
    data: JSON.stringify({
        "items": [{
            "categoryId": 14606
        }]                    
    })
});
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.