Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Directus (DrWade) n8n node for the resource Presets and operation Update Multiple allows you to update multiple Directus preset records in a single API call. This is particularly useful when you need to apply changes (such as layout or configuration updates) to several presets at once, streamlining bulk management tasks within your Directus instance.

Common scenarios:

  • Updating the layout or other properties of several saved views or filters for users.
  • Bulk-modifying preset configurations after a schema change.
  • Automating administrative tasks that require updating many presets simultaneously.

Practical example:
Suppose you have several user interface presets for different roles in your Directus project, and you want to change their layout from "cards" to "tabular". Instead of updating each preset individually, you can use this operation to update all relevant presets in one go.


Properties

Name Type Meaning
Data (JSON) json The JSON object specifying which presets to update and what data to set.
Required fields:
- keys: Array of primary keys (IDs) of the presets to update.
- data: Object with the new preset properties.

Example value:

{
  "keys": [15, 64],
  "data": {
    "layout": "tabular"
  }
}
  • keys: List of preset IDs to update.
  • data: Any valid preset object properties to be updated.

Output

  • The output will be a JSON object containing the result of the update operation.
  • The structure typically reflects the updated preset objects as returned by the Directus API.
  • If an error occurs and "Continue On Fail" is enabled, the output will contain an error field with the error message.

Example output:

{
  "id": 15,
  "layout": "tabular",
  // ...other preset fields
}

or, if multiple presets are updated:

[
  { "id": 15, "layout": "tabular", /* ... */ },
  { "id": 64, "layout": "tabular", /* ... */ }
]

Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires a configured directusApi credential in n8n with sufficient permissions to update presets.

Troubleshooting

Common issues:

  • Invalid or missing credentials: Ensure your Directus API credentials are correctly set up in n8n.
  • Malformed JSON in "Data (JSON)": Double-check your input; invalid JSON will cause parsing errors.
  • Missing required fields: Both keys and data must be present in the input object.
  • Insufficient permissions: The API user must have permission to update presets in Directus.

Error messages:

  • "Cannot read property 'keys' of undefined": Your input JSON is missing the keys array.
  • "Request failed with status code 403": The API user does not have permission to update presets.
  • "Unexpected token ... in JSON": There is a syntax error in your JSON input.

How to resolve:

  • Validate your JSON using a linter or online tool.
  • Check that the IDs in keys exist and are accessible.
  • Ensure your API user has the correct role/permissions in Directus.

Links and References

Discussion