Add a List Item
To add a new list item to an existing list in WebEOC Nexus, use the AddListItem endpoint.
| Description | Adds a new list item to a list in WebEOC Nexus |
|---|---|
| URL | /lists/[listname] |
| Method | POST |
| Parameters |
|
Review the parameter definitions and examples of how to use the AddListItem endpoint in JavaScript and C# calls. This method can be called in two ways:
-
If you provide [listname] in the URL, a new list item with name = [listname] is created.
-
If you provide [listItem], the whole tree of items, sub-items, sub sub items (and so on) can be created in one call.
Parameters
| Variable Name | Type | Description | Required |
|---|---|---|---|
| listName | String | Name of the WebEOC Nexus list to which the new item is to be added. | True (URL) |
| listItem | WebEOCListItem | List item to be added. See Custom Objects. | False |
WebEOCListItem: Custom Objects
The WebEOCListItem, returned when using the AddListItem endpoint, contains several unique, custom objects.
| Variable Name | Type | Description |
|---|---|---|
| name | String | Name of the list item |
| subitems | List of WebEOCListItems | Recursive list of itself |
| color | Hex color code string | Color associated with the list item |
Examples
JavaScript Call
var newListItem = {
name: 'New List',
subitems: [{
name: "valueOne",
color: "#ff0000"
}]
};
await fetch(`${baseUrl}/lists/New List`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(newListItem)
})
C# Call
public async Task AddListItem()
{
using (var httpClient = new HttpClient(httpClientHandler))
{
var newListItem = new
{
name = "New List",
subitems = new object[] {
new {
name="valueOne",
color="#ff0000"
}
}
};
var serializedInformation =
JsonConvert.SerializeObject(newListItem);
await httpClient.PostAsync($"{baseUrl}/lists/New List",
new StringContent(serializedInformation, Encoding.UTF8,
"application/json"));
}
}
Related Concepts
Related Tasks