Actions109
- Activity Actions
- Assets Actions
- Authentication Actions
- Collections Actions
- Extensions Actions
- Fields Actions
- Files Actions
- Folders Actions
- Items Actions
- Permissions Actions
- Presets Actions
- Relations Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
- Webhooks Actions
Overview
The node integrates with the Directus API to manage various resources, including Roles. Specifically, for the Roles - Update operation, it allows updating an existing role by specifying its unique ID and providing partial data to modify. This is useful in scenarios where you need to programmatically change role properties such as permissions, icons, or other metadata within a Directus-managed project.
Practical examples include:
- Updating the icon of a role to better represent its purpose.
- Modifying role permissions or descriptions dynamically based on external triggers.
- Automating role updates during deployment or synchronization processes.
Properties
| Name | Meaning |
|---|---|
| ID | The primary key (unique identifier) of the role to update. |
| Data (JSON) | A partial JSON object representing the fields of the role to update. For example, changing the icon: { "icon": "attractions" }. This should conform to the Directus role object. |
Output
The output is a JSON object representing the updated role as returned by the Directus API after the PATCH request. It contains the updated fields of the role, reflecting the changes made.
No binary data output is involved in this operation.
Example output snippet:
{
"id": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
"name": "Editor",
"icon": "attractions",
"description": "Can edit content",
...
}
Dependencies
- Requires an active connection to a Directus instance via its REST API.
- Needs an API authentication token credential configured in n8n to authorize requests.
- The node uses the Directus API endpoint
PATCH /roles/{id}to perform the update.
Troubleshooting
- Invalid ID: If the provided role ID does not exist, the API will return an error indicating the resource was not found. Verify the ID is correct.
- Malformed JSON Data: Ensure the JSON provided in the Data property is valid and matches the expected structure of a role object.
- Insufficient Permissions: The API token used must have permission to update roles; otherwise, authorization errors will occur.
- Network Issues: Connectivity problems with the Directus server will cause request failures.
- API Errors: Any errors returned by the Directus API (e.g., validation errors) will be surfaced. Review the error message for details.
To resolve errors:
- Double-check the role ID and JSON data format.
- Confirm API credentials and permissions.
- Inspect error messages for specific API response details.
Links and References
- Directus Role Object Documentation: https://docs.directus.io/reference/api/system/roles/#the-role-object
- Directus API Reference (Roles): https://docs.directus.io/reference/api/system/roles/
- n8n HTTP Request Node (for understanding API calls): https://docs.n8n.io/nodes/n8n-nodes-base.httpRequest/