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 Role API Calls?
The Role API calls will allow users with the API role, or API key, to add and delete roles in WebReports.
ExampleRole API callsinclude the following:
- Add (takes a list of UDFs)
- Delete (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:
Add:/extapi/APIWebReport/AddRoles
Delete:/extapi/APIWebReport/DeleteRoles
Role API Endpoints using the API Key Controller
/extapi/APIWebReport/AddRoles
/extapi/APIWebReport/DeleteRoles
Add Report Assignments:
Adding report assignments takes a list of "NewReportAssignment"
public class NewReportAssignment
{
public string Name { get; set; }
public string Category { get; set; }
public string Description { get; set; }
public string Connections { get; set; }
public string Roles { get; set; }
public string Types { get; set; }
public int Expiration { get; set; }
}
(Creating a List of NewReportAssignment to send to the API)
Dim ReportAssignments as new list(of NewReportAssignment)
(Creating new Report Assignments)
**NOTE** Connections and Roles can take multiple Connections/Roles separated by ;
Dim ReportAssignment1 As New NewReportAssignment With {.Name = "MyName", .Category = "MyCategory", .Connections = "MyConnection1;MyConnection2", .Description = "MyDescription", .Roles = "Role1;Role2;Role3"}
Dim ReportAssignment2 As New NewReportAssignment With {.Name = "MyName2", .Category = "MyCategory2", .Connections = "MyConnection3;MyConnection4", .Description = "MyDescription2", .Roles = "Role1;Role2;Role3"}
ReportAssignments.Add(ReportAssignment1)
ReportAssignments.Add(ReportAssignment2)
(Sending the List of string (roles) to the API Call)
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(ReportAssignments, Formatting.Indented), Encoding.UTF8, "application/json")
Dim openResponse = client.PostAsync("server/extapi/APIWebReport/AddReportAssignments", Params).GetAwaiter().GetResult()
Delete Report Assignments:
Deleting Report Assignments takes a list of Integers (The ID's of the Report Assignments, Use the GetReportAssignments Method to retrieve a list of ID's).
(Creating a List of int(IDs) to send to the API)
Dim IDs as new list(of int)
IDs.Add(1)
IDs.Add(2)
(Sending the List of string (roles) to the API Call)
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(IDs, Formatting.Indented), Encoding.UTF8, "application/json")
Dim openResponse = client.PostAsync("server/extapi/APIWebReport/DeleteReportAssignments", Params).GetAwaiter().GetResult()
Update Report Assignments:
Updating Report Assignments (Category and Description) takes a list of "UpdateReportAssignment"
public class UpdateReportAssignment
{
public string Name { get; set; }
public string Category { get; set; }
public string Description { get; set; }
}
(Creating a List of string (roles) to send to the API)
Dim UpdateAssignments As New List(Of UpdateReportAssignment)
UpdateAssignments.Add(New UpdateReportAssignment with {.Name = "Report1.vdm", .Category = "MyNewCat", .Description = "MyNewDesc")
UpdateAssignments.Add(New UpdateReportAssignment with {.Name = "Report2.vdm", .Category = "MyNewCat2", .Description = "MyNewDesc2")
(Sending the List of string (roles) to the API Call)
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(UpdateAssignments, Formatting.Indented), Encoding.UTF8, "application/json")
Dim openResponse = client.PostAsync("server/extapi/APIWebReport/UpdateReportAssignments", Params).GetAwaiter().GetResult()
Comments
0 comments
Please sign in to leave a comment.