External Bodies
Load response bodies from external JSON or Excel files in moclojer. Perfect for large datasets, API proxies, and transforming spreadsheets into REST APIs with minimal configuration.
π― Why Use External Bodies?
flowchart LR
A[HTTP Request] --> B[moclojer]
B --> C{External Body?}
C -->|Yes| D{Provider Type}
C -->|No| E[Use inline body]
D -->|json| F[Load JSON file]
D -->|xlsx| G[Load Excel file]
F --> H[Parse JSON]
G --> I[Convert to JSON]
H --> J[Return Response]
I --> J
E --> Jπ Configuration
External Body Fields
Field
Required
Description
π Global Configuration
When to Use Global Configuration
Path Resolution Rules
π JSON Provider
Local File
Remote URL (API Proxy)
Template Variables in Paths
π Excel (XLSX) Provider
id
name
department
salary
Multiple Sheets
π Real-World Use Cases
1. Product Catalog from Excel
2. Multi-Environment API Proxy
3. Testing with Real Data Samples
4. Financial Reports from Spreadsheets
π§ Advanced Patterns
Combining Template Variables and External Bodies
Fallback to Inline Body
Conditional External Bodies
β
Best Practices
π File Organization
Recommended Structure
π§ͺ Testing External Bodies
Verify File Paths
Test with curl
Validate JSON Files
π Debugging
Common Issues
Issue
Solution
Enable Debug Logging
Check File Paths
π Performance Considerations
Provider
File Size
Load Time
Caching
π¨ Important Notes
π See Also
Last updated
Was this helpful?