Update DropDowns
EasyLife 365 Collaboration API facilitates the direct updating of dropdown field options. This feature enables the dynamic modification of dropdown field options based on external data sources. For instance, when new departments are added to the Human Resources system, the list of departments on EasyLife 365 Collaboration can be automatically updated.
Route
| Method | Route | What it does | Delegated scope | Application role | Rate limit | Response codes |
|---|---|---|---|---|---|---|
| PATCH | /admin/v1/fields/select/{field-name}/ | Updates the values of a dropdown field | Config.ReadWrite.All | Collab.Manage.ReadWrite.All | Create, update, delete | 204, 400, 401, 403, 404, 429 |
Permissions
| Permission Type | Permissions |
|---|---|
| Delegated (work or school account) | https://api.easylife365.cloud/admin/Config.ReadWrite.All |
| Application | Collab.Manage.ReadWrite.All |
The read role Collab.Manage.Read.All cannot change dropdown values and answers 403. Application permissions always require admin consent. See Call the API as an application.
HTTP Request
PATCH https://api.easylife365.cloud/admin/v1/fields/select/{field-name}/
Content-Type: application/json
HTTP request headers
| Header | Value |
|---|---|
| Authorization | Bearer token. (Required) |
| Content-Type | application/json |
Request Body
| Property | Type | Description |
|---|---|---|
| defaultValue | String | Default value of the dropdown. (Optional) |
| options | Object | List of key/value pairs representing dropdown options. The key is the option key, and the value is the displayed option value. (Required) |
| translations | Object | List of translated values in different languages. Supported languages are "de", "it", "fr", "es", "pl", "tr", "nl". (Optional) |
Response
A successful call answers 204 and has no body.
Errors
Errors are application/problem+json with code, title, detail and requestId. The list of codes is on Call the API as an application. These are the ones you can expect here:
| Status | Code | When |
|---|---|---|
| 400 | InvalidPayload | The field name is empty, the options are missing, a key of an option has a character other than a letter, a digit or -, the default value is not one of the keys, a translation has a different number of values than there are options, a language is not supported, or the field is not a dropdown. The detail says which. |
| 403 | NotAllowed | The role is missing, or it is the read role. |
| 404 | NotFound | The field does not exist. |
{
"type": "https://docs.easylife365.cloud/errors/invalid-payload",
"title": "The request could not be accepted.",
"status": 400,
"detail": "Default value must be one of the keys",
"code": "InvalidPayload",
"requestId": "0HNG2K4V7QJ3D:00000012"
}
Example 1: Update dropdown field
This example updates the dropdown field "el-check-428" with the default value "key1" and includes the translation in German.
PATCH https://api.easylife365.cloud/admin/v1/fields/select/el-check-428/
Content-Type: application/json
{
"defaultValue": "key1",
"options": {
"key1": "value1",
"key2": "value2"
},
"translations": {
"de": [
"value1de",
"value2de"
]
}
}
Example 2: Update Dropdown Field using PowerShell
The following example demonstrates updating a field using PowerShell. Before executing the script, ensure you've registered an application and obtained the TenantId and ClientId. Also, retrieve the correct URI and scope from this document.
$tenantId = "[TENANT_ID]"
$scope = "[SCOPE]"
$uri = "[URI]"
az login --tenant $tenantId | Out-Null
$accessToken = az account get-access-token `
--tenant $tenantId `
--scope $scope `
--query accessToken `
--output tsv
# Create object with values to pass to the API.
$body = @{
defaultValue = "key1"
options = @{
key1 = "value1"
key2 = "value2"
}
translations = @{
de = @(
"value1de",
"value2de"
)
}
}
# Invoke the API and capture responses.
$jsonBody = $body | ConvertTo-Json -Depth 5 -Compress
$encodedBody = [System.Text.Encoding]::UTF8.GetBytes($jsonBody)
$headers = @{
"Authorization"= "Bearer $($accessToken)"
"Content-Type" = "application/json"
}
Write-Information "Updating field with: $jsonBody" -InformationAction Continue
Invoke-RestMethod -Method PATCH -Uri $uri -Headers $headers -Body $encodedBody
Example 3: Update a dropdown field as an application (PowerShell)
Get the token as shown in Call the API as an application and keep it in $accessToken.
$uri = "https://api.easylife365.cloud/admin/v1/fields/select/el-check-428/"
$body = @{
defaultValue = "key1"
options = @{ key1 = "value1"; key2 = "value2" }
} | ConvertTo-Json -Depth 5
$headers = @{ Authorization = "Bearer $accessToken" }
Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -ContentType "application/json" -Body $body
On the Insiders ring, use the host api.insiders.easylife365.cloud.