Blog posts and categories

    List all categories associated to a blog post

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

    Parameters

    • objectId - the ID of the blog (integer)
    • categoryId the Id of the category (integer)
    • objectType - category object type is 56 (integer)
    • displayable should be 1 (integer)
    • siteId the ID of the site (integer)
    • category json object, listing default category fields (object)

    Response

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

    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/1383385/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": 1383385,
          "categoryId": 155310,
          "objectType": 56,
          "displayable": 1,
          "siteId": 246884,
          "category": {
            "id": 155310,
            "siteId": 246884,
            "categoryTypeId": 43,
            "parentId": 14606,
            "category": "Company Private",
            "publicAccess": false,
            "Default": false,
            "Deleted": false
          }
        }
      ],
      "totalItemsCount": 1,
      "skip": 0,
      "limit": 10
    }

    Add a category to a blogpost

    Using this method you can assign a category to a blogpost.

    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/blogposts/[blogID]/categories
      • 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.

    Accepts and returns JSON as Content-Type.


    Request:

    POST /webresources/api/v3/sites/current/blogposts/[blogpostID]/categories HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

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

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/blogposts/303870/categories",
        data: {
            "items": [{
                "categoryId": 14610,
            }]
        },
        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);
    })

    Remove a category from a blogpost

    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/blogposts/[blogpostID]/categories
      • 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/blogposts/[blogID]/categories 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/[blogID]/categories
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample code

    var access_token = BCAPI.Helper.Site.getAccessToken();
    
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/blogposts/303870/categories?items=[{'objectId':303870,'categoryId':14610,'objectType':56,'displayable':1}]",
        type: "DELETE",
        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);
    })