Directus icon

Directus

Consume Directus API

Overview

The node provides various operations to interact with the Directus API, a headless CMS and API platform. Specifically, for the Utilities resource and the Get a Random String operation, the node requests a random string from the Directus backend.

This operation is useful when you need to generate unique identifiers, tokens, or any random string data within your workflow without implementing custom logic. For example, you might use it to create random passwords, session keys, or unique filenames dynamically.

Properties

Name Meaning
Additional Fields Collection of optional fields; currently supports:
- Length Length of the random string to generate (number, minimum value 1). If not set, default length is used by the API.

Output

The output JSON contains the generated random string under the result property. The structure is:

{
  "result": "randomlyGeneratedString"
}

If the API returns a different format (e.g., a primitive string), it is wrapped into an object with the result key for consistency.

No binary data output is produced by this operation.

Dependencies

  • Requires connection to a Directus instance via its API.
  • Needs an API authentication token credential configured in n8n to authorize requests to the Directus API.
  • The node uses the Directus API endpoint utils/random/string with an optional query parameter for length.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication errors.
    • Specifying a non-positive number or invalid type for the length field may result in API errors or unexpected results.
    • Network connectivity issues to the Directus server will cause request failures.
  • Error messages:

    • Authentication errors typically indicate invalid or expired API tokens; reconfigure credentials.
    • Validation errors from the API about the length parameter suggest providing a valid positive integer.
    • JSON parsing errors may occur if input parameters are malformed; ensure correct types.

Links and References


This summary focuses on the Utilities > Get a Random String operation extracted from the provided source code and property definitions.

Discussion