Comments

    List all comments

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

    Response body

    An array of the first 10 items; each object has the following properties:

    • id (integer)
    • createDate (dateTime)
    • objectType (integer)
      • 1 - WebPages
      • 7 - Announcements
      • 9 - Faq
      • 26 - Catalogue
      • 27 - Product
      • 35 - Webapp
      • 56 - Blog
    • siteId (integer)
    • objectId - must have a value and must belong to an existing resource (integer)
    • rating - must be between 0 and 5 inclusive (integer)
    • feedback - must be a maximum of 4000 characters (string)
    • entityId - must belong to an existing customer (integer)
    • status (integer)
      • 1 - Approved
      • 2 - Pending
      • 3 - Spam

    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/comments",
        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": 1,
          "createDate": "2016-04-19T14:50:22.45",
          "objectType": 56,
          "siteId": 38592,
          "objectId": 86329,
          "rating": 0,
          "feedback": "comment 1",
          "website": "",
          "entityId": 21543,
          "status": 1
        },
        {
          "id": 2,
          "createDate": "2016-04-19T14:50:25.997",
          "objectType": 56,
          "siteId": 38592,
          "objectId": 86329,
          "rating": 0,
          "feedback": "comment 2",
          "website": "",
          "entityId": 21543,
          "status": 1
        }
      "totalItemsCount": 2,
      "skip": 0,
      "limit": 10
    }

    Get details of a comment

    Get comment with id = X

    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/comments/[comment_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 comment as a JSON object

    • id (integer)
    • createDate (dateTime)
    • objectType (integer)
      • 1 - WebPages
      • 7 - Announcements
      • 9 - Faq
      • 26 - Catalogue
      • 27 - Product
      • 35 - Webapp
      • 56 - Blog
    • siteId (integer)
    • objectId - must have a value and must belong to an existing resource (integer)
    • rating - must be between 0 and 5 inclusive (integer)
    • feedback - must be a maximum of 4000 characters (string)
    • entityId - must belong to an existing customer (integer)
    • status (integer)
      • 1 - Approved
      • 2 - Pending
      • 3 - Spam

    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/comments/1",
        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": 1,
      "createDate": "2016-04-19T14:50:22.45",
      "objectType": 56,
      "siteId": 38592,
      "objectId": 86329,
      "rating": 0,
      "feedback": "comment 1",
      "website": "",
      "entityId": null,
      "status": 1
    }

    Create a comment

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

    Parameters

    • createDate (dateTime) - Optional
    • objectType (integer) - Mandatory
    • siteId (integer) - Optional
    • objectId (integer) - Mandatory
    • rating (integer) - Optional
    • feedback (string) - Mandatory
    • entityId (integer) - Optional
    • status (integer) - Mandatory
    • website (string) - Mandatory

    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/comments",
        type: "POST",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
    	processData: false,
        data: JSON.stringify({
          "rating": 0,
          "feedback": "comment 1 - test post 1",
          "entityId": 12344,
          "status": 1,
          "createDate": "2016-09-08T19:47:08.417",
          "website":"example.com",
          "objectType":56,
          "objectId": 840181,
          "siteId": 2455866
        })
    });
    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.

    201 Created

    500 - An unexpected error occurred

    10620 - Value passed in the request body is not found valid

    Accepts and returns JSON as Content-Type.

    Update a comment

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

    Parameters

    • createDate (dateTime)
    • objectType (integer)
    • siteId (integer)
    • objectId (integer)
    • rating (integer)
    • feedback (string)
    • entityId (integer)
    • status (integer)

    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/comments/1",
        type: "PUT",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        },
        data: JSON.stringify({
          "feedback": "comment modified",
        })
        
    });
    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.

    204 OK

    Accepts and returns JSON as Content-Type.

    Delete a comment

    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/comments/[comment_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/comments/1 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/comments/[comment_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/comments/[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.