Skip to main content

Files

When using TesmonLang to make HTTP requests or to send messages with Kafka, you can include the content of a file as part of the request. This is particularly useful for dynamic data that changes frequently or for large data sets that are not practical to include directly in the DSL. This is advantageous in various scenarios, especially when dealing with content that cannot be easily copy-pasted. This includes binary data, various document formats (e.g., PDF, DOCX), image files (e.g., PNG, JPEG), and other media types (e.g., audio and video files). Utilizing external files for the request body facilitates easy updates and management of the content.

FILE Path Types

  • Relative Path: FILE:./path/to/user_data.json - The path is relative to the location of the TesmonLang project
  • Absolute Path: FILE:/tmp/path/to/user_data.json - You could also specify an absolute path if necessary, but it's recommended to use relative paths for better portability across different environments.

DSL Example with FILE Syntax for HTTP Request Body

Here's an example where the body of an HTTP POST request is loaded from a JSON file:

method: POST
baseUrl: https://example.com
path: /api/users
headers:
Content-Type: application/json
body: FILE:./path/to/user_data.json

The request body is dynamically loaded from the user_data.json file, containing JSON formatted user data.