API Calls for Managing Users' Roles in WebReports
Trouble seeing the images? Right click on images and open in new tab to enlarge or zoom in on the page (Ctrl + mousewheel).
In this article we provide detail on the API calls for managing Roles in WebReports.
Why Use the Users' Roles API Calls?
The Users' Roles API calls will allow users with the API role, or API key, to assign and remove roles to / from users in WebReports.
Example Users' Roles API calls include the following:
- AssignRolesToUsers (takes a list of UDFs)
- RemoveRolesFromUsers (takes a list of UDFs)
API Prerequisites:
- Must have the API role in WebReports
- Established Connection/Cookie
Video Tutorial:
Not yet available.
Structure / Examples of Role API Calls
Role API Endpoints:
AssignRolesToUsers: /api/Service/AssignRolesToUsers
RemoveRolesFromUsers: /api/Service/RemoveRolesFromUsers
Role API Endpoints using the API Key Controller
/extapi/APIWebReport/AssignRolesToUsers
/extapi/APIWebReport/RemoveRolesFromUsers
Users' Roles Parameter Structure:
When sending a call to either AssignRolesToUsers/RemoveRolesFromUsers, the controller is looking for a list of "UsersRoles". Below is the structure for "UsersRoles".
public class UsersRoles
{
public string UserName { get; set; }
public List<string> Roles { get; set; }
}
AssignRolesToUsers:
Dim Users As New List(of UsersRoles)
(Creating a List of string (roles) to send to the API)
Dim Roles As New List(Of string)
Roles.Add("Role1")
Roles.Add("Role2")
Users.Add(Roles)
(Sending the List of string (roles) to the API Call)
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(Users, Formatting.Indented), Encoding.UTF8, "application/json")
Dim openResponse = client.PostAsync("server/api/Service/AssignRolesToUsers", Params).GetAwaiter().GetResult()
RemoveRolesFromUsers:
Dim Users As New List(of UsersRoles)
(Creating a List of string (roles) to send to the API)
Dim Roles As New List(Of string)
Roles.Add("Role1")
Roles.Add("Role2")
Users.Add(Roles)
(Sending the List of string (roles) to the API Call)
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(Users, Formatting.Indented), Encoding.UTF8, "application/json")
Dim openResponse = client.PostAsync("server/api/Service/RemoveRolesFromUsers", Params).GetAwaiter().GetResult()
Comments
0 comments
Please sign in to leave a comment.