Description:
The APITool executor currently hardcodes JSON response parsing in execute_api_tool:
# qtype/interpreter/executors/invoke_tool_executor.py, line ~199
result = response.json()
This causes failures when APIs return non-JSON content types like CSV, plain text, or XML, even when the appropriate Accept header is set.
Example:
An API endpoint returns CSV data with Accept: text/csv header:
- id: get_csv_data
type: APITool
endpoint: "https://api.example.com/export"
method: GET
headers:
accept: text/csv
Error:
error: API request failed: Expecting value: line 1 column 1 (char 0)
Proposed Solution:
- Add an optional
response_type field to APITool (default: json)
- Support
json, text, binary, and auto (based on Content-Type header)
- Parse response accordingly:
json: response.json()
text: response.text
binary: response.content
auto: detect from Content-Type header
Workaround:
Use a Python function tool with requests library for full control over response handling.