Get Roles

Gets a list of roles available on a specified site.

Request

  • Method: GET
  • 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: /api/v2/admin/sites/[siteId]/roles
    • Alternatively, use 'current' instead of siteId
  • Authorization header: This should contain the authorization token. Here is how to obtain the token.
  • Required Permissions: Administer System

Response

Returns a list of site role objects, with the below fields:

  • id - the role id in the database (integer)
  • name - the user friendly name, to be used as label (string)

Accepts and returns JSON as Content-Type.


Request:

GET /api/v2/admin/sites/current/roles HTTPS/1.1
Connection: keep-alive
Content-Type: application/json
Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811

Response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: length

{
    "links": [{
        "rel": "self",
        "uri": "https://api-ava.worldsecuresystems.com/api/v2/admin/sites/%7BsiteId%7D/roles"
    }, {
        "rel": "previous",
        "uri": null
    }, {
        "rel": "next",
        "uri": null
    }],
    "items": [{
        "id": 10000,
        "name": "Administrators"
    }, {
        "id": 10013,
        "name": "Users"
    }],
    "totalItemsCount": 2,
    "itemsPerPageCount": 1000,
    "currentPage": 1
}

Sample code

var request = $.ajax({
    url: "/api/v2/admin/sites/current/roles",
    type: "GET",
    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);
})

Error codes

This method will return the following error codes:

  • 200 - success
  • 401 - when authentication token is incorrect
  • 403 - when the user attempting the call does not have the proper permissions