Training Day

HTTP Script

A modern, JSON-based HTTP client for FileMaker that simplifies complex API requests by providing a fetch-like interface over FileMaker's Insert from URL script step.

Introduction

FileMaker's built-in "Insert from URL" script step provides basic HTTP functionality through cURL commands, but constructing complex requests requires string concatenation and careful character escaping, which can be error-prone and difficult to maintain. The HTTP Script addresses these challenges by providing a more developer-friendly interface inspired by the web standard fetch API.

Instead of manually building cURL command strings, you can now structure your requests using JSON objects - a format that FileMaker handles naturally. The script takes care of all the complex string manipulation and character escaping behind the scenes, converting your JSON request configuration into the appropriate cURL commands for FileMaker's Insert from URL step.

Key Features

  • Flexible Data Handling: Supports multiple data formats and content types, including JSON, binary, and form data.
  • Comprehensive Response Processing: Extracts and formats response headers and body, handling various content types and attachments.
  • Debugging Support: Provides detailed logging of requests and responses when debugging is enabled.
  • Error Handling: Captures and processes errors, ensuring robust execution.

Usage

To use this script, call it using the FileMaker "Perform Script" step:

Perform Script [ "HTTP Script" ; JSONObject ]

Script Parameter

The script accepts a single JSON object parameter with the following properties:

PropertyTypeDescription
urlstringThe URL to send the request to
queryobject(Optional) Name-value pairs for URL query parameters. For nested querystrings, use |_ and _| to represent [ and ]
headersobject(Optional) Key-value pairs for request headers. Example: { "Accept": "application/json" }
authobject(Optional) Basic authentication credentials
auth.userstringBasic auth username
auth.passwordstringBasic auth password
datastring/object(Optional) Data to send with POST, PUT, PATCH requests. For nested form-urlencoded data, use |_ and _| to represent [ and ]

Return Value

The script returns a JSON object with the following structure:

PropertyTypeDescription
responseobjectThe successful response object
response.okbooleanTrue if the response code is in the 200-299 range
response.codenumberHTTP status code
response.statusstringHTTP status message
response.headersobjectResponse headers
response.bodyanyResponse body content
response.traceobject(Optional) Request trace if options.trace = true
response.durationobject(Optional) Request duration if options.duration = true

Error Handling

If an error occurs, the script returns an error object:

PropertyTypeDescription
errorobjectThe error object
error.errorCodenumberError code

Debug Mode

Set the $$ENV_DEBUG_HTTP variable to enable detailed request/response logging.

Resources

The HTTP Script is part of the mfm-http project, which is available on GitHub. You can find the sample file and test file in the repository:

📦 GitHub Repository: proofgeist/mfm-http

The repository includes:

  • Sample FileMaker file (mfm-HTTP.fmp12)
  • DDR XML export (mfm-HTTP.xml)
  • Latest version: 2.0.0 (Released March 17, 2025)

On this page