Defined Field API Calls (UDFs)
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 example API calls for managing UDFs for WebReports.
Why Use Defined Field API Calls?
These API calls will allow users with the API role to manage Defined Fields (UDFs) for the WebReports environment. Example API calls include Add, Delete, Update, etc.
API Prerequisites:
- Require the user to have the API role in WebReports
- Established Connection/Cookie
Video Tutorial:
Not yet available.
Example Defined Field API Calls
UDF Parameter Structure:
public class UDFParameter
{
public string definedFieldName { get; set; }
public string definedFieldValue { get; set; }
public string definedFieldDesc { get; set; }
public string user { get; set; }
public string value { get; set; }
public string queryIdentifier { get; set; }
}
Set User Defined Field:
Dim Param = New UDFParameter With {
.definedFieldName = "Test3",
.user = "Administrator",
.value = "test12345"
}
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(Param, Formatting.Indented), Encoding.UTF8, "application/json")
Dim response = Con.client.PostAsync(Con.DConnection.Server & "/api/Service/SetUserDefinedField", Params).GetAwaiter().GetResult()
If response.IsSuccessStatusCode Then
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
Else
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
End If
Add Defined Field:
Dim Param = New UDFParameter With {
.definedFieldName = "Test3",
.definedFieldDesc = "desc",
.queryIdentifier = "QueryIdentifier"
}
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(Param, Formatting.Indented), Encoding.UTF8, "application/json")
Dim response = Con.client.PostAsync(Con.DConnection.Server & "/api/Service/AddDefinedField", Params).GetAwaiter().GetResult()
If response.IsSuccessStatusCode Then
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
Else
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
End If
Update Defined Field:
Dim Param = New UDFParameter With {
.definedFieldName = "Test3",
.definedFieldDesc = "desc",
.queryIdentifier = "QueryIdentifier"
}
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(Param, Formatting.Indented), Encoding.UTF8, "application/json")
Dim response = Con.client.PostAsync(Con.DConnection.Server & "/api/Service/UpdateDefinedField", Params).GetAwaiter().GetResult()
If response.IsSuccessStatusCode Then
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
Else
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
End If
Delete Defined Field:
Dim Param = New UDFParameter With {
.definedFieldName = "Test3"
}
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(Param, Formatting.Indented), Encoding.UTF8, "application/json")
Dim response = Con.client.PostAsync(Con.DConnection.Server & "/api/Service/DelDefinedField", Params).GetAwaiter().GetResult()
If response.IsSuccessStatusCode Then
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
Else
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
End If
Remove User Defined Field:
Dim Param = New UDFParameter With {
.definedFieldName = "Test3",
.user = "Administrator"
}
Dim Params As StringContent = New StringContent(JsonConvert.SerializeObject(Param, Formatting.Indented), Encoding.UTF8, "application/json")
Dim response = Con.client.PostAsync(Con.DConnection.Server & "/api/Service/RemoveUserDefinedField", Params).GetAwaiter().GetResult()
If response.IsSuccessStatusCode Then
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
Else
Return response.Content.ReadAsStringAsync().GetAwaiter().GetResult()
End If
Comments
0 comments
Please sign in to leave a comment.