Generic API icon

Generic API

Node genérico para integração com APIs REST

Overview

This node provides a generic interface to interact with REST APIs by performing common CRUD operations on any specified resource. It is designed to be flexible, allowing users to specify the API resource and operation dynamically, making it useful for integrating with various RESTful services without needing a dedicated node for each API.

For the Atualizar (Update) operation specifically, the node updates an existing record identified by its ID with new data provided in JSON format. This is beneficial when you need to modify existing entries in an external system via its API, such as updating user details, product information, or order statuses.

Practical example:
You have a CRM system exposing a REST API. Using this node, you can update a contact's information by specifying the resource as "contacts", the operation as "update", providing the contact's ID, and the updated data in JSON format.

Properties

Name Meaning
ID The unique identifier of the record to update.
Dados Para Atualizar JSON-formatted data containing the fields and values to update in the specified record.
Opções Adicionais Additional options including:
- Headers Customizados Custom HTTP headers to include in the request.
- Query Parameters Extra query parameters to append to the URL.
- Timeout Request timeout in milliseconds (default 30000 ms).
- Continuar Em Erro Whether to continue workflow execution if an error occurs during this operation (boolean).

Output

The node outputs the response from the API call in the json field of each item. For the update operation, this typically contains the updated record data returned by the API after a successful update.

If multiple items are processed, each output item corresponds to one input item, paired accordingly.

No binary data output is produced by this node.

Dependencies

  • Requires an API key credential configured in n8n to authenticate requests to the target REST API.
  • Uses a helper class internally to make HTTP requests (GenericApiHelpers).
  • The node expects the target API to support standard REST methods (PUT for update) and return JSON responses.

Troubleshooting

  • Common issues:

    • Invalid or missing ID: The update operation requires a valid record ID; ensure this is correctly provided.
    • Malformed JSON in "Dados Para Atualizar": The update data must be valid JSON; syntax errors will cause failures.
    • API authentication errors: Ensure the API key credential is correctly set up and has permissions to update records.
    • Timeout errors: If the API is slow to respond, consider increasing the timeout value in additional options.
  • Error messages:

    • "Operação desconhecida": Indicates an unsupported operation was selected; verify the operation parameter.
    • API error responses are passed through; check the error message and details in the output if "Continuar Em Erro" is enabled.
    • JSON parsing errors for input data will throw exceptions; validate JSON before running the node.

Links and References

Discussion