API Calls for Managing Users UDFs 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 UDFs in WebReports.
Why Use the User UDF Management API Calls?
The UDF management API calls will allow users with the API role, or API key, to modify user UDFs in WebReports.
Example Defined Field API callsinclude the following:
- SetUsersDefinedFields(takes a list of UsersUDFs)
- RemoveUsersDefinedFields(takes a list of UsersUDFs)
API Prerequisites:
- Must have the API role in WebReports
- Established Connection/Cookie
Video Tutorial:
Not yet available.
Structure / Examples of Defined Field API Calls
UDF API Endpoints:
Set User's Defined Fields: /api/Service/SetUsersDefinedFields
Remove User's Defined Fields: /api/Service/RemoveUsersDefinedFields
Informational API Endpoints using the API Key Controller
/extapi/APIWebReport/SetUsersDefinedFields
/extapi/APIWebReport/RemoveUsersDefinedFields
UDF Parameter Structure:
When sending a call to either SetUsersDefinedFields or RemoveUsersDefinedFields, the controller is looking for a list of "UsersUDFs". Below is the structure for a "UsersUDFs".
public class UsersUDFs
{
public string UserName { get; set; }
public List<UserUDF> UDFs { get; set; }
}
In the the "UsersUDFs" structure, there is also a list of "UserUDF". This list is the UDF's that will be updated/removed on the user. The structure of "UserUDF" is below.
public class UserUDF
{
public string Name { get; set; }
public string Value { get; set; }
}
Set User's Defined Fields':
(Creating a List of UsersUDFs to send to the API)
Dim MyUsersUDFs As New List(Of UsersUDFs)
Dim MyUser As New UsersUDFs With {.Name = "User1"}
Dim MyUserUDFs As New List(Of UserUDF)
(Adding UserUDF values to the MyUsersUDFs list to be set on the User)
MyUserUDFs.Add(New UserUDF With {.Name = "UDF1", .Value = "User 1 UDF 1"})
MyUserUDFs.Add(New UserUDF With {.Name = "UDF2", .Value = "User 1 UDF 2"})
(Setting the list of UserUDFs to the User)
MyUser.UDFs = MyUserUDFs
(Adding the User to the list of MyUsersUDFs)
MyUsersUDFs.Add(MyUser)
(Creating a Second User)
MyUser = New UsersUDFs With {.Name = "User2"}
MyUserUDFs = New List(Of UserUDF)
(Adding UserUDF values to the MyUsersUDFs list to be set on the User)
MyUserUDFs.Add(New UserUDF With {.Name = "UDF1", .Value = "User 2 UDF 1"})
MyUserUDFs.Add(New UserUDF With {.Name = "UDF2", .Value = "User 2 UDF 2"})
(Setting the list of UserUDFs to the Second User)
MyUser.UDFs = MyUserUDFs
(Adding the Second User to the list of MyUsersUDFs)
MyUsersUDFs.Add(MyUser)
(Sending the List of UDF to the API Call)
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(MyUsersUDFs, Formatting.Indented), Encoding.UTF8, "application/json")
Dim openResponse = client.PostAsync("server/api/Service/SetUsersDefinedFields", Params).GetAwaiter().GetResult()
Remove User's Defined Fields':
(Creating a List of UsersUDFs to send to the API)
Dim MyUsersUDFs As New List(Of UsersUDFs)
Dim MyUser As New UsersUDFs With {.Name = "User1"}
Dim MyUserUDFs As New List(Of UserUDF)
(Adding UserUDF values to the MyUsersUDFs list to be removed from the user)
MyUserUDFs.Add(New UserUDF With {.Name = "UDF1"})
MyUserUDFs.Add(New UserUDF With {.Name = "UDF2"})
(Setting the list of UserUDFs to the User)
MyUser.UDFs = MyUserUDFs
(Adding the User to the list of MyUsersUDFs)
MyUsersUDFs.Add(MyUser)
(Creating a Second User)
MyUser = New UsersUDFs With {.Name = "User2"}
MyUserUDFs = New List(Of UserUDF)
(Adding UserUDF values to the MyUsersUDFs list to be removed from the user)
MyUserUDFs.Add(New UserUDF With {.Name = "UDF1"})
MyUserUDFs.Add(New UserUDF With {.Name = "UDF2"})
(Setting the list of UserUDFs to the Second User)
MyUser.UDFs = MyUserUDFs
(Adding the Second User to the list of MyUsersUDFs)
MyUsersUDFs.Add(MyUser)
(Sending the List of UDF to the API Call)
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(MyUsersUDFs, Formatting.Indented), Encoding.UTF8, "application/json")
Dim openResponse = client.PostAsync("server/api/Service/RemoveUsersDefinedFields", Params).GetAwaiter().GetResult()
Comments
0 comments
Please sign in to leave a comment.