Directus icon

Directus

Consume Directus API

Overview

The node integrates with the Directus API to perform various operations on different resources. Specifically, for the Items resource and the Update Multiple operation, it allows users to update multiple items within a specified collection in bulk. This is useful when you need to modify several records at once without making individual update calls for each item.

Typical use cases include:

  • Bulk updating the status or category of multiple articles in a content management system.
  • Changing multiple user attributes simultaneously.
  • Applying batch modifications to inventory items in an e-commerce database.

For example, you might update the "status" field to "published" for items with IDs 1 and 2 in the "articles" collection.

Properties

Name Meaning
Collection The unique name of the parent collection where the items reside. Example: articles.
Data (JSON) JSON object containing the keys (item IDs) to update and the partial item data to apply. For example:
json<br>{<br> "keys": [1, 2],<br> "data": {<br> "status": "published"<br> }<br>}<br>

Output

The output is a JSON object representing the response from the Directus API after attempting to update the specified items. It typically contains information about the updated items or the result of the bulk update operation.

No binary data output is produced by this operation.

Dependencies

  • Requires an active connection to a Directus instance via an API key credential.
  • The node uses the Directus REST API endpoints to perform operations.
  • Proper permissions must be granted to the API key to update items in the specified collection.

Troubleshooting

  • Invalid Collection Name: If the collection name does not exist or is misspelled, the API will return an error. Verify the collection name is correct.
  • Malformed JSON Data: The Data (JSON) property must be valid JSON. Errors in parsing will cause failures. Use proper JSON formatting.
  • Insufficient Permissions: The API key used must have update permissions on the target collection; otherwise, the request will fail.
  • Empty Keys Array: Ensure that the keys array in the data JSON is not empty; otherwise, no items will be updated.
  • API Rate Limits or Network Issues: Network connectivity problems or API rate limits may cause errors. Retry or check network/API status.

Common error messages usually come directly from the Directus API and indicate issues such as authentication failure, invalid parameters, or permission denials.

Links and References

Discussion