Ask AI
Skip to main content

Fetch a file

Function: Fetch a file

Effortlessly connect and fetch a file, simplifying data integration and enhancing the functionality of your applications through a user-friendly, code-free interface. This action allows your application to retrieve files from external web services or APIs.

Input

  • Authentication method: Specify how your application will prove its identity to the external service.
    • Options:
      • Basic authentication: Uses a username and password.
      • Bearer Token: Uses a special token in the request header.
      • API Token: Uses an API key in the request header.
      • None: No authentication is used.
  • Username: (Visible if "Basic authentication" is selected) The username for basic authentication.
  • Password: (Visible if "Basic authentication" is selected) The password for basic authentication.
  • Token: (Visible if "Bearer Token" or "API Token" is selected) The secret token or API key for authentication.
  • Headers: A collection of key-value pairs to send as custom headers with your request. This is useful for providing additional information to the server.
  • Endpoint: The complete web address (URL) of the file you want to fetch. This is a required input.
  • Query parameters: A collection of key-value pairs to add to the end of the URL, often used for filtering or specifying data.
  • Method: The type of request your application will make to the external service. This is a required input.
    • Options:
      • GET: Used to retrieve data. (Default)
      • POST: Used to send data to the server, typically to create or update a resource.
  • Request body: (Visible if "POST" method is selected) A collection of key-value pairs representing the data you want to send to the external service.
  • File name: The name you want to give to the downloaded file within your application. If not provided, it defaults to "downloaded_file".
  • File description: A brief explanation or note about the downloaded file.

Output

  • Response: A variable that will hold the downloaded file. This file can then be used in other parts of your application.
  • Status: A variable that will indicate the outcome of the API call.
    • SUCCESS: The file was fetched successfully.
    • NOT_FOUND: The specified endpoint (URL) could not be found on the remote service.
    • UNAUTHORIZED: The provided authentication credentials were not accepted.
    • BAD_REQUEST: The request sent to the API was invalid (e.g., missing required data in the body).
    • TYPE_ERROR: An error occurred while trying to determine the file type.

Execution Flow

Real-Life Examples

Example 1: Downloading a Public Report

Imagine you need to regularly download a public sales report from a government website. This report doesn't require any special login.

  • Inputs:
    • Authentication method: None
    • Endpoint: https://www.example.gov/reports/sales_data_q3_2023.pdf
    • Method: GET
    • File name: Q3_Sales_Report
    • File description: Quarter 3 Sales Data from Government
  • Result: The PDF report sales_data_q3_2023.pdf is downloaded and stored in your application as a file named Q3_Sales_Report in the Response variable. The Status variable will be set to SUCCESS.

Example 2: Fetching an Invoice from an Accounting System

Your application needs to retrieve a specific invoice from an external accounting system that uses an API key for secure access.

  • Inputs:
    • Authentication method: API Token
    • Token: your_secret_api_key_12345
    • Endpoint: https://api.accounting.com/invoices/download
    • Query parameters:
      • invoiceId: INV-2023-001
      • format: json
    • Method: GET
    • File name: Invoice_INV-2023-001
    • File description: Invoice details for customer ABC
  • Result: The JSON file containing the invoice details for INV-2023-001 is downloaded and saved as Invoice_INV-2023-001 in the Response variable. The Status variable will be set to SUCCESS. If the API key was incorrect, Status would be UNAUTHORIZED.

Example 3: Submitting a Request and Receiving a Generated Document

You have a form in your application where users request a custom certificate. After the user submits the form, your application calls an external service to generate the certificate and then downloads it. This service requires a username and password and expects the request details in the body.

  • Inputs:
    • Authentication method: Basic authentication
    • Username: cert_generator_user
    • Password: secure_password_123
    • Endpoint: https://cert-service.com/generate
    • Method: POST
    • Request body:
      • userName: John Doe
      • courseName: Advanced No-Code Development
      • dateCompleted: 2023-10-26
    • File name: John_Doe_Certificate
    • File description: Certificate for John Doe
  • Result: The external service generates a certificate based on the provided details. This certificate (e.g., a PDF) is then downloaded and stored in your application as John_Doe_Certificate in the Response variable. The Status variable will be SUCCESS. If the request body was malformed, Status would be BAD_REQUEST.