URLs
GET api.ashx/v2/{application}/{id}/roles.xml (or .json)
LIST roles for an application.
GET api.ashx/v2/{application}/{id}/roles/permissions.xml (or .json)
LIST roles with permissions for an application.
GET api.ashx/v2/{application}/{id}/roles/permissions/{permissionid}.xml (or .json)
LIST roles with permission for an application.
GET api.ashx/v2/{application}/{id}/roles/permissions/user/{userid}.xml (or .json)
LIST roles with permissions for a user by user id for an application.
GET api.ashx/v2/{application}/{id}/roles/permissions/user/{username}.xml (or .json)
LIST roles with permissions for a user by username for an application.
GET api.ashx/v2/{application}/{id}/roles/user/{userid}.xml (or .json)
LIST roles for a user by user id for an application.
GET api.ashx/v2/{application}/{id}/roles/user/{username}.xml (or .json)
LIST roles for a user by username for an application.
GET api.ashx/v2/roles.xml (or .json)
LIST all roles.
GET api.ashx/v2/roles/permissions.xml (or .json)
LIST all roles with permissions.
GET api.ashx/v2/roles/permissions/{permissionid}.xml (or .json)
LIST roles with permission.
GET api.ashx/v2/roles/permissions/user/{userid}.xml (or .json)
LIST roles with permissions for a user by user id.
GET api.ashx/v2/roles/permissions/user/{username}.xml (or .json)
LIST roles with permissions for a user by username.
GET api.ashx/v2/roles/user/{userid}.xml (or .json)
LIST roles for a user by user id.
GET api.ashx/v2/roles/user/{username}.xml (or .json)
LIST roles for a user by username.
Request Parameters
Name | Type | Description | Required | Default | Options |
---|---|---|---|---|---|
Application | string | Application | Required | ||
Id | int? | Id | Optional | ||
UserId | int? | Either UserId or Username are required when using include=user | Optional | ||
Username | string | Either UserId or Username are required when using include=user | Optional | ||
IncludePermissions | bool | Include Permissions | Optional | ||
PermissionId | string | Permission Id | Optional | ||
Include | string | Options for include are user, granted, or denied. Ex: include=granted. | Optional | ||
IncludeWithAvatarOnly | bool | Will only return roles that have avatars. For use with include=user only. | Optional | ||
PageSize | int? | Specify the number of results to return per page. If not set the default is 20. The max is 100. | Optional | ||
PageIndex | int? | Specify the page number of paged results to return. Zero-based index. If not specified the default is 0. | Optional |
Example Requests
C# REST SDK
This example uses the REST SDK to access the Community REST API within a .Net C# application. In the example, USER_NAME
is the user name of the effective user for the request and OAUTH_CLIENT_ID
and OAUTH_SECRET
are the OAuth client ID and secret, respectively, associated to this application as configured in Administration > Integration > OAuth Clients with the "Client Credentials" grant type enabled. See the documentation for the REST SDK for more details about installation, configuration, and usage options.
var host = new ClientCredentialsRestHost("USER_NAME", "https://mysite.com/", "OAUTH_CLIENT_ID", "OAUTH_SECRET"); var response = host.GetToDynamic(2, "{application}/{id}/roles.json", false, new RestGetOptions { PathParameters = new System.Collections.Specialized.NameValueCollection { { "application", "application" }, { "id", "6" } } });
Widget Javascript
This example uses the rest JavaScript API to access the Community REST API within the Community web UI. When accessing the REST API through the javascript API, the effective user is the current contextual user of the web interface.
jQuery.telligent.evolution.get({ url: jQuery.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/{application}/{id}/roles.json', data: { 'application': 'application', 'id': '6' }, success: function(response) { } });
cURL
This example uses the cURL command-line HTTP utility. ENCODED_TOKEN
in the example is the base64-encoded concatenation of the user's API key (created from the user's profile), a colon (:), and the user's user name. Learn more about using the REST API.
curl -H "Rest-User-Token: ENCODED_TOKEN" -X GET https://mysite.com/api.ashx/v2/application/6/roles.xml
Example Responses
XML
<?xml version="1.0" encoding="utf-16"?> <Response> <Info> <Message>string</Message> <Message>string</Message> </Info> <Warnings> <Message>string</Message> <Message>string</Message> </Warnings> <Errors> <Message>string</Message> <Message>string</Message> </Errors> <Roles> <Role> <Id>6</Id> <Name>name</Name> <Description>description</Description> <GroupId>25</GroupId> <IsSystemRole>true</IsSystemRole> <AvatarUrl>avatarurl</AvatarUrl> <PermissionEntries> <PermissionEntry> <Id>49fec544-6df7-4a82-872b-f8be586d5e9e</Id> <PermissionId>permissionid</PermissionId> <Name>name</Name> <IsAllowed>true</IsAllowed> <IsImmediate>true</IsImmediate> </PermissionEntry> <PermissionEntry> <Id>9f5a6721-639d-4e1d-ab6a-ce63b7750f46</Id> <PermissionId>permissionid</PermissionId> <Name>name</Name> <IsAllowed>true</IsAllowed> <IsImmediate>true</IsImmediate> </PermissionEntry> </PermissionEntries> </Role> <Role> <Id>8</Id> <Name>name</Name> <Description>description</Description> <GroupId>4</GroupId> <IsSystemRole>true</IsSystemRole> <AvatarUrl>avatarurl</AvatarUrl> <PermissionEntries> <PermissionEntry> <Id>fe65240b-044c-4292-9946-f10e0361ecff</Id> <PermissionId>permissionid</PermissionId> <Name>name</Name> <IsAllowed>true</IsAllowed> <IsImmediate>true</IsImmediate> </PermissionEntry> <PermissionEntry> <Id>2d525bad-c4df-470d-a193-a1c6d66e5c3e</Id> <PermissionId>permissionid</PermissionId> <Name>name</Name> <IsAllowed>true</IsAllowed> <IsImmediate>true</IsImmediate> </PermissionEntry> </PermissionEntries> </Role> </Roles> </Response>
JSON
{ "Roles": [ { "Id": 6, "Name": "name", "Description": "description", "GroupId": 25, "IsSystemRole": true, "ImageUrl": "", "AvatarUrl": "avatarurl", "PermissionEntries": [ { "Id": "49fec544-6df7-4a82-872b-f8be586d5e9e", "PermissionId": "permissionid", "Name": "name", "IsAllowed": true, "IsImmediate": true }, { "Id": "9f5a6721-639d-4e1d-ab6a-ce63b7750f46", "PermissionId": "permissionid", "Name": "name", "IsAllowed": true, "IsImmediate": true } ] }, { "Id": 8, "Name": "name", "Description": "description", "GroupId": 4, "IsSystemRole": true, "ImageUrl": "", "AvatarUrl": "avatarurl", "PermissionEntries": [ { "Id": "fe65240b-044c-4292-9946-f10e0361ecff", "PermissionId": "permissionid", "Name": "name", "IsAllowed": true, "IsImmediate": true }, { "Id": "2d525bad-c4df-470d-a193-a1c6d66e5c3e", "PermissionId": "permissionid", "Name": "name", "IsAllowed": true, "IsImmediate": true } ] } ], "Info": [ "string", "string" ], "Warnings": [ "string", "string" ], "Errors": [ "string", "string" ] }