(Quick Reference)

6 Assign authority to user - Reference Documentation

Version: 2.1

6 Assign authority to user

6.1 List

Service: List of assigned users to authorities (roles)

Description: This web service returns a json list of couples (user,authority).

URL:

https://BASE_URL/api/VERSION/userAuthorities

Method: GET

Parameters:

Pagination parameters:

NameDescriptionTypeRequiredPossible values
maxLimits the number of resources requested to return.Integerno 
offsetTells where to start returning records from the entire set of results.Integerno 
orderOrders ascending or descending.Integernoasc,desc
sortOrders the results by the specified field.Stringno 

The max parameter is set to 100 by default.

Filters parameters:

NameDescriptionTypeRequiredExample values
dateCreated_gtFilters by the resource's creation date time and operator greater thanDateno2016-08-15T14:52:48Z
dateCreated_gteFilters by the resource's creation date time and operator greater than or equalDateno 
dateCreated_ltFilters by the resource's creation date time and operator less thanDateno 
dateCreated_lteFilters by the resource's creation date time and operator less than or equalDateno 
lastUpdated_gtFilters by the resource's last-modified date time and operator greater thanDateno 
lastUpdated_gteFilters by the resource's last-modified date time and operator greater than or equalDateno 
lastUpdated_ltFilters by the resource's last-modified date time and operator less thanDateno 
lastUpdated_lteFilters by the resource's last-modified date time and operator less than or equalDateno 
employeeReferenceWildcard search by the resource's employee referenceStringno 

Dates should be formatted as the ISO-8601 format (YYYY-MM-DDTHH:MM:SSZ)

Success Output

Success case: response.status=200

{
    "paging": {
        "total": 5,
        "max": 1,
        "offset": 0,
        "previous": null,
        "next": "/api/v2.0/userAuthorities?max=1&offset=1&sort=dateCreated&order=asc"
    },
    "data": [
        {
            "id": 1,
            "user": {
                "id": 1,
                "reference": "emp04",
                "href": "/api/v2.0/users/1"
            },
            "authority": {
                "id": 24,
                "name": "Sales",
                "href": "/api/v2.0/authorities/24"
            },
            "dateCreated": "2015-12-15T09:03:49Z",
            "lastUpdated": "2015-12-15T09:03:49Z"
        }
    ]
}

Failure Output

Failure case:response.status = 400
{
   "error": "invalid_param",
   "error_description": "The parameters [dateCreated_gta] you provided are not valid for this request."
}
{
    "error": "invalid_datetime_format",
    "error_description": "Invalid datetime filter (not ISO-8601 formatted): [2016-08-1Z]"
}
Failure case:response.status = 500
{
   "error": "server_error",
   "error_description": "Oops! Something went wrong..."
}

6.2 Show

Service: Show an assigned user to an authority (role)

Description: This web service return an existing assigned user to an authority object of the specified id in JSON format

Method: GET

URL:

https://BASE_URL/api/VERSION/userAuthorities/{id}

Parameters:

NameDescriptionTypeRequiredExample values
idid of the desired recordLongYes100

URL with external_id:

https://BASE_URL/api/VERSION/userAuthorities/reference/{userId}/{authorityId}

Parameters:

NameDescriptionTypeRequiredExamples values
userIdreference of the userStringYesU-002
authorityIdname of the authorityStringYesCEO

Success Output

Success case: response.status = 200
{
    "id": 1,
    "user": {
        "id": 1,
        "reference": "emp04",
        "href": "/api/v2.0/users/1"
    },
    "authority": {
        "id": 24,
        "name": "Sales",
        "href": "/api/v2.0/authorities/24"
    },
    "dateCreated": "2015-12-15T09:03:49Z",
    "lastUpdated": "2015-12-15T09:03:49Z"
}

Failure Output

Failure case:response.status = 400
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter id you provided is not valid for this request."
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The userAuthority with the id 100 doesn't exist."
}

6.3 Create

Service: Assign a route to an employee

Description: This web service is used to assign an employee which is not assigned before to a route

URL:

https://BASE_URL/api/VERSION/userAuthorities

Method: POST

Request content type: application/json

Parameters:

NameDescriptionTypeRequiredExample values
userIdthe id of user to be assignedLong/StringYes1
authorityIdthe id of the authorityLong/StringYes2
useExternalIdBy default, it is set to false. set it to true if you want to use external ids.Booleannotrue , false

Success Output

Success case: response.status = 201
{
    "id": 34,
    "user": {
        "id": 37,
        "reference": "test",
        "href": "/api/v2.0/users/37"
    },
    "authority": {
        "id": 19,
        "name": "Marketing Director",
        "href": "/api/v2.0/authorities/19"
    },
    "dateCreated": "2017-02-16T10:46:24Z",
    "lastUpdated": "2017-02-16T10:46:24Z"
}

Failure Output

Failure case:response.status = 400
{
    "error": "invalid_param_type",
    "error_description": "The type of parameter authorityId you provided is not valid for this request."
}
{
    "error": "missing_param",
    "error_description": "userId parameter is missing"
}
{
    "error": "already_assigned",
    "error_description": "User is already assigned to authority: ADMIN."
}
{
  "error": "save_failed",
  "error_description": "Failed to save instance"
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The user with the id 11111 doesn't exist."
}
Failure case:response.status = 500
{
  "error": "server_error",
  "error_description": "Oops! Something went wrong..."
}

6.4 Update

Service: Update an assigned user to an authority (role)

Description: This web service is used to update an assigned user to an authority

Method: PUT

Request content type: application/json

URL:

https://BASE_URL/api/VERSION/userAuthorities/{id}

Parameters:

NameDescriptionTypeRequiredExample values
idid of the desired record to updateLongYes123
userIdthe id of user to be assignedLongYes1
authorityIdthe id of the authorityLongYes2

URL with external_id:

https://BASE_URL/api/VERSION/userAuthorities/reference/{userId}/{authorityId}

Parameters:

NameDescriptionTypeRequiredExamples values
userIdreference of the userStringYesU-002
authorityIdname of the authorityStringYesCEO

Success Output

Success case: response.status = 200
{
    "id": 34,
    "user": {
        "id": 37,
        "reference": "test",
        "href": "/api/v2.0/users/37"
    },
    "authority": {
        "id": 21,
        "name": "Sales Director",
        "href": "/api/v2.0/authorities/21"
    },
    "dateCreated": "2017-02-16T10:46:24Z",
    "lastUpdated": "2017-02-16T10:54:51Z"
}

Failure Output

Failure case:response.status = 400
{
    "error": "already_assigned",
    "error_description": "User is already assigned to authority: CEO."
}

{
    "error": "invalid_param_type",
    "error_description": "The type of parameter authorityId you provided is not valid for this request."
}

{
  "error": "save_failed",
  "error_description": "Failed to save instance"
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The authority with the id 17000 doesn't exist."
}

Failure case:response.status = 500
{
  "error": "server_error",
  "error_description": "Oops! Something went wrong..."
}

6.5 Delete

Service: Dissociate a user from an authority (role)

Description: This web service is used to dissociate an assigned user to a role and delete it.

Method: DELETE

URL:

https://BASE_URL/api/VERSION/userAuthorities/{id}

Parameters:

NameDescriptionTypeRequiredExample values
idid of the desired record to deleteLongYes7

URL with external_id:

https://BASE_URL/api/VERSION/userAuthorities/reference/{userId}/{authorityId}

Parameters:

NameDescriptionTypeRequiredExamples values
userIdreference of the userStringYesU-002
authorityIdname of the authorityStringYesCEO

Success Output

Success case: response.status = 200
{
  "success": "true",
  "success_description": "Instance deleted successfully"
}

Failure Output

Failure case:response.status = 400
{
	"error":"invalid_param_type",
 	"error_description": "The type of parameter id you provided is not valid for this request."
}

{
	"error": "delete_failed",
	"error_description": "Failed to delete instance."
}

Failure case:response.status = 404
{
    "error": "not_found",
    "error_description": "The user authority with the id 35 doesn't exist."
}

Failure case:response.status = 500
{
     "error": "server_error",
     "error_description": "Oops! Something went wrong..."
}