Skip to main content

getUserRoles

A Graze API GET request that returns the specified user's roles from the database.

Back to Graze API EndPoint Reference.

Request arguments

Endpoint getUserRoles takes the following request arguments:

Name

Type

Required

Description

auth_token

String

Yes

A valid auth_token returned from the authenticate request. Alternatively, basic authenticate headers can be used in place of this parameter. See the authenticate endpoint for more information and usage examples.

user_id

Number

No, if you specify username.

User ID.

username

String

No, if you specify user_id.

A valid username.

Response

Endpoint getUserRoles returns the following response:

Successful requests return an array of JSON objects containing the following:

Name

Type

Description

JSON Object

JSON

An array javascript object containing the role IDs, the role names and the role descriptions assigned to the user.

Examples

The following examples demonstrate typical use of endpoint getUserRoles:

Request example

Example cURL request to return the assigned roles for user "bigfish917":

curl -G -u graze:graze -k -v "https://localhost/graze/v1/getUserRoles" \
--data-urlencode "username=bigfish917"

Response example

Example response returning the roles assigned to the user:

[
    {
        "id" : 2,
        "name" : "Administrator",
        "description" : "Administrator"
    },
    {
        "id" : 4,
        "name" : "Operator",
        "description" : "Operator"
    },
    {
        "id" : 5,
        "name" : "Customer",
        "description" : "Customer"
    }
]