Send QBO HTTP Request
A specialized script for interacting with the QuickBooks Online API from FileMaker, handling authentication, token management, and error handling.
Introduction
The "Send QBO HTTP Request" script provides a specialized interface for interacting with the QuickBooks Online (QBO) API from FileMaker. This script handles the complexities of QBO authentication, token management, request formatting, and error handling to simplify integration with QuickBooks Online services.
Unlike direct HTTP requests, QBO API calls require OAuth token management, including automatic token refresh when access tokens expire. This script encapsulates that logic while providing a clean interface for making various QBO API calls.
Key Features
- Automatic Token Management: Detects expired access tokens and refreshes them automatically
- Standardized Error Handling: Converts QBO API errors into consistent FileMaker error formats
- Retry Logic: Automatically retries requests after token refresh when needed
- Optional Debug Logging: Logs requests and responses when debugging is enabled
Usage
To use this script, call it using the FileMaker "Perform Script" step:
Script Parameter
The script accepts a single JSON object parameter with the following properties:
| Property | Type | Description |
|---|---|---|
path | string | The endpoint path for the API call (required) |
query | object | (Optional) Name-value pairs that serialize to what comes after the "?" in the URL |
data | string/object | (Optional) Data to send with POST, PUT, PATCH requests |
Return Value
On success, the script returns the body of the QBO API response as a JSON object.
Error Handling
If an error occurs, the script returns an error object with the following structure:
| Property | Type | Description |
|---|---|---|
code | number | Error code |
message | string | A description of the error |
qboFault | object | (Optional) Detailed error from QBO if available |
Common error codes:
-100: QBO API Bad Request-101: Unauthorized-102: QBO Internal Server Error-103: QBO API Service Unavailable
Implementation Details
The script follows this process flow:
- Request Validation: Verifies that required parameters are present
- Token Management: Checks if the access token is expired and refreshes if needed
- Request Construction: Builds the complete request URL and adds authorization headers
- API Call: Makes the HTTP request to the QBO API
- Token Refresh & Retry: If a 401 error is received, refreshes the token and retries
- Response Handling: Processes the response, handling errors consistently
- Debug Logging: Logs the request and response if debugging is enabled
Dependencies
This script depends on:
- The "Refresh Access Token" script for token renewal
- The "HTTP ( request )" script for making HTTP requests
- The "QBO Logger" script for debug logging
- A "QBOSettings" table to store token information
Debug Mode
Set the $$DEBUG variable to enable detailed request/response logging to the "QBO.log" file.
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.
Get Changed Records
Retrieves records from QuickBooks Online that have been modified since a specified timestamp, supporting pagination for large data sets.