Directus (flagbit) icon

Directus (flagbit)

Consume Directus API

Overview

This node is designed to update an existing item within a specified collection in a Directus data source. It allows users to modify the fields of an item by providing its unique ID, the collection it belongs to, and the partial data to update. This operation is useful when you need to programmatically change or correct data entries without replacing the entire item.

Common scenarios include:

  • Updating article content such as title or body text.
  • Modifying user profile information stored in a collection.
  • Adjusting inventory details like stock counts or descriptions.

Example: Updating the title and body of an article with ID "15" in the "articles" collection.

Properties

Name Meaning
ID Unique identifier of the item to update.
Collection Name The name of the parent collection where the item exists. Options are dynamically loaded.
Data (JSON) Partial JSON object representing the fields to update on the item. Must follow item schema.

Output

The node outputs the updated item object in JSON format reflecting the changes made. This output corresponds to the updated state of the item after the operation completes successfully.

If the node supports binary data output, it would typically represent any file attachments or media linked to the item, but this is not explicitly indicated here.

Dependencies

  • Requires connection to a Directus API instance.
  • Needs appropriate API authentication credentials (e.g., an API key or token) configured in n8n.
  • The "Collection Name" property options are dynamically loaded via a method that fetches available collections from Directus.

Troubleshooting

  • Invalid ID or Collection: If the provided item ID or collection name does not exist, the node will fail to find the item to update. Verify the correctness of these inputs.
  • Malformed JSON Data: The "Data (JSON)" field must be valid JSON matching the expected item schema. Invalid JSON or incorrect field names can cause errors.
  • Authentication Errors: Ensure the API credentials are valid and have permissions to update items in the specified collection.
  • API Rate Limits or Network Issues: These may cause request failures; check connectivity and API usage limits.

Links and References

Discussion