This article provides examples of API calls for adding, deleting, and updating report assignments in WebReports.
Why Use the Report Assignment API Calls?
Use these calls to manage report assignments programmatically.
-
Add: Send a list of
NewReportAssignmentobjects. - Delete: Send a list of report assignment IDs.
-
Update: Send a list of
UpdateReportAssignmentobjects to update the category and description.
API Prerequisites
The existing examples use an authenticated connection. Review Establish Connection / Store Cookie and ensure the calling user has the API role in WebReports.
Structure and Examples of Report Assignment API Calls
The examples below use the following endpoints:
-
Add:
/extapi/APIWebReport/AddReportAssignments -
Delete:
/extapi/APIWebReport/DeleteReportAssignments -
Update:
/extapi/APIWebReport/UpdateReportAssignments
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 new report assignments 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 report assignment IDs 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 UpdateReportAssignment objects 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 report assignment updates 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.