News

    Get News

    Gets the list of news items available.

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

    Response

    The details for the specified customer ID in JSON format.

    • id - the id of the news item(integer)
    • siteId - the id of the site(integer)
    • roleId - id of the role responsible(integer)
    • subject - question body(string)
    • body - answer body(string)
    • templateId - template assigned to news(integer)
    • weight - weight value(integer)
    • createBy - admin user id(integer)
    • createDate - date of news item creation(datetime)
    • latUpdateBy - admin user that performed latest update(integer)
    • lastUpdateDate - most recent update date(datetime)
    • eventFromDate - associated start date(datetime)
    • eventToDate - associated end date(datetime)
    • releaseDate release date(datetime)
    • expiryDate - date of item expiry(datetime)
    • enabled - active state, true or false(boolean)
    • deleted deleted state, true or false(boolean)
    • displayable display state, true or false(boolean)
    • parentId id of parent node(integer)
    • urlPrefix URL prefix(string)
    • slug item slug(string)
    • url full item url(string)

    The response is paginated, you can return only a few of the customer's fields. Take a look at the API V3: sorting and filtering for additional switches you can use.

    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.


    Request:

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

    Response:

    {
       "items": [
         {
          "id": 57625,
          "siteId": 1211552,
          "roleId": -1,
          "subject": "Company Announces Record Profits",
          "body": "
    You can now write about your latest news, announcements and much\nmore. When a customer clicks the link to the Announcement this page is\ndisplayed to them. It's now much easier to manage and maintain.
    
    \n
    This Announcement was created to provide you with an example. Update it to suit your needs or delete if not required.
    
    \r\n",
          "templateId": 0,
          "weight": null,
          "createBy": 267621,
          "createDate": "2013-11-25T09:13:03.45",
          "lastUpdateBy": 267621,
          "lastUpdateDate": "2013-11-25T09:13:03.45",
          "eventFromDate": "2011-05-31T10:00:00",
          "eventToDate": "2011-05-31T10:00:00",
          "releaseDate": "2011-05-31T10:00:00",
          "expiryDate": "9998-12-31T15:00:00",
          "enabled": true,
          "deleted": false,
          "displayable": true,
          "parentId": 7,
          "urlPrefix": "announcements",
          "slug": "company-announces-record-profits",
          "url": "/announcements/company-announces-record-profits"
        },
        {
          "id": 57627,
          "siteId": 1211552,
          "roleId": -1,
          "subject": "Important Notice to Shareholders",
          "body": "
    You can now write about your latest news, announcements and much\nmore. When a customer clicks the link to the Announcement this page is\ndisplayed to them. It's now much easier to manage and maintain.
    
    \n
    This Announcement was created to provide you with an example. Update it to suit your needs or delete if not required.
    
    \r\n",
          "templateId": 0,
          "weight": null,
          "createBy": 267621,
          "createDate": "2013-11-25T09:13:03.45",
          "lastUpdateBy": 267621,
          "lastUpdateDate": "2013-11-25T09:13:03.45",
          "eventFromDate": "2011-05-31T10:00:00",
          "eventToDate": "2011-05-31T10:00:00",
          "releaseDate": "2011-05-31T10:00:00",
          "expiryDate": "9998-12-31T15:00:00",
          "enabled": true,
          "deleted": false,
          "displayable": true,
          "parentId": 7,
          "urlPrefix": "announcements",
          "slug": "important-notice-to-shareholders",
          "url": "/announcements/important-notice-to-shareholders"
        }
     ],
      "totalItemsCount": 2,
      "skip": 0,
      "limit": 10
    }

    Sample code

    List all the news items on the site

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/news",
    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);
    })

    Create a new News item

    Using this method you can add a news item to your site.

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

    Parameters

    • id - the id of the news item(integer)
    • siteId - the id of the site(integer)
    • roleId - id of the role responsible(integer)
    • subject - question body(string)
    • body - answer body(string)
    • templateId - template assigned to news(integer)
    • weight - weight value(integer)
    • createBy - admin user id(integer)
    • createDate - date of news item creation(datetime)
    • latUpdateBy - admin user that performed latest update(integer)
    • lastUpdateDate - most recent update date(datetime)
    • eventFromDate - associated start date(datetime)
    • eventToDate - associated end date(datetime)
    • releaseDate release date(datetime)
    • expiryDate - date of item expiry(datetime)
    • enabled - active state, true or false(boolean)
    • deleted deleted state, true or false(boolean)
    • displayable display state, true or false(boolean)
    • parentId id of parent node(integer)
    • urlPrefix URL prefix(string)
    • slug item slug(string)
    • url full item url(string)

    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/news HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    
    
    {
          "id": 57625,
          "siteId": 1211552,
          "roleId": -1,
          "subject": "Company Announces Record Profits",
          "body": "You can now write about your latest news"
    		"templateId": 0,
        "weight": null,
        "createBy": 267621,
        "createDate": "2013-11-25T09:13:03.45",
        "lastUpdateBy": 267621,
        "lastUpdateDate": "2013-11-25T09:13:03.45",
        "eventFromDate": "2011-05-31T10:00:00",
        "eventToDate": "2011-05-31T10:00:00",
        "releaseDate": "2011-05-31T10:00:00",
        "expiryDate": "9998-12-31T15:00:00",
        "enabled": true,
        "deleted": false,
        "displayable": true,
        "parentId": 7,
        "urlPrefix": "announcements",
        "slug": "company-announces-record-profits",
        "url": "/announcements/company-announces-record-profits"
    }
    

    Response:

    
    HTTP/1.1 201 CREATED
    Location: /webresources/api/v3/sites/current/news
    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/news",
      data:JSON.stringify({
      "roleId": -1,
      "subject": "Company Announces Record Profits",
      "body": "<p>You can now write about your latest news, announcements and much nmore.",
      "templateId": 0,
      "weight": null,
      "createBy": 267621,
      "createDate": "2013-11-25T09:13:03.45",
      "lastUpdateBy": 267621,
      "lastUpdateDate": "2013-11-25T09:13:03.45",
      "eventFromDate": "2011-05-31T10:00:00",
      "eventToDate": "2011-05-31T10:00:00",
      "releaseDate": "2011-05-31T10:00:00",
      "expiryDate": "9998-12-31T15:00:00",
      "enabled": true,
      "deleted": false,
      "displayable": true,
      "parentId": 7,
      "urlPrefix": "announcements",
      "slug": "company-announces-record-profits",
      "url": "/announcements/company-announces-record-profits"
      }),
      type: "POST",    
        contentType: "application/json",
        headers: {
             "Authorization": BCAPI.Helper.Site.getAccessToken()
        }
    });
    request.done(function(data) {
        console.log(data);
    })
        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 news resource

    Using this method you can edit a news item.

    Request

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

    Parameters

    • id - the id of the news item(integer)
    • siteId - the id of the site(integer)
    • roleId - id of the role responsible(integer)
    • subject - question body(string)
    • body - answer body(string)
    • templateId - template assigned to news(integer)
    • weight - weight value(integer)
    • createBy - admin user id(integer)
    • createDate - date of news item creation(datetime)
    • latUpdateBy - admin user that performed latest update(integer)
    • lastUpdateDate - most recent update date(datetime)
    • eventFromDate - associated start date(datetime)
    • eventToDate - associated end date(datetime)
    • releaseDate release date(datetime)
    • expiryDate - date of item expiry(datetime)
    • enabled - active state, true or false(boolean)
    • deleted deleted state, true or false(boolean)
    • displayable display state, true or false(boolean)
    • parentId id of parent node(integer)
    • urlPrefix URL prefix(string)
    • slug item slug(string)
    • url full item url(string)

    Response

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

    Accepts and returns JSON as Content-Type.


    Request:

    PUT /webresources/api/v3/sites/current/faqs/[faqId] HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    
    
    {
          "id": 57625,
          "siteId": 1211552,
          "roleId": -1,
          "subject": "Company Announces New Record Profits"
    }

    Response:

    
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/faqs/[faqId]
    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/news/57625",
        data:JOSN.stringify( { "id": 57625, "siteId": 1211552, "roleId": -1, "subject": "Company Announces New Record Profits" } ),
        type: "PUT", contentType: "application/json", headers: { "Authorization": BCAPI.Helper.Site.getAccessToken() } }); request.done(function(data) { console.log(data); }) 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 an FAQ item

    Delete a Frequently Asked Question.

    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/news/[faqId]
      • 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/news/[newsId] 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/news/[newsId]
    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/news/57625",
        type: "DELETE", contentType: "application/json", headers: { "Authorization": $.cookie('access_token') } }); request.done(function(data) { console.log(data); }) 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); })