File Tools
Most of the file commands in Captivate can also take a url parameter to download the file from an online resource.
API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Open a database file (sqlite), run a query, and return the results. If sql and table are not provided, this will return all rows from all tables in the database.
optional id to track this command, will be returned in the response
Full file path. Also see openFileDialog.
If provided, will return the full content of the table using the same parsing as used by getFileContent.
SQL query to run against the database.
successful operation
bad request
GET /api/command/runDbQuery HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "getFileContent",
"reply": "getFileContent",
"success": false
}
}API access: Over HTTP and TCP, this command needs Full API Access. Over the WebSocket API, Broadcast and Enterprise can use it.
Takes a supplied string of structured data (xml, csv, other json) and converts it to a JSON object..
optional id to track this command, will be returned in the response
String contents that should be parsed and converted.
<item><child name="hello">world</child></item>type of the input string (xml, csv, json)
xmlboolean value, if true, the data will be flattened into 1 level deep simplified object of key-value pairs.
1successful operation
bad request
GET /api/command/convertToJson HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "convertToJson",
"json": {},
"reply": "convertToJson",
"success": true
}
}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Execute a web request through the Captivate Backend. When a browser blocks network access, you can use this command to fetch data from a URL.
optional id to track this command, will be returned in the response
Url to fetch.
https://newbluefx.comHTTP method to use (GET, POST, PUT, DELETE, etc). Default is GET.
HTTP headers to include in the request, formatted as a JSON object with key-value pairs. Encode as JSON when sending in a query parameter.
HTTP body to include in the request as a string. Typically used with POST or PUT requests. Remember to set the appropriate Content-Type header if needed. For large requests, post to the /api endpoint directly.
successful operation
bad request
GET /api/command/fetchUrl?url=text HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "fetchUrl",
"reply": "fetchUrl",
"success": true
}
}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Download an image file from the Internet or parse it from a data url and save it to a local temporary file..
optional id to track this command, will be returned in the response
Optional: Full url to the image file
Optional: a "data url" construct like "data:image/jpeg;base64,BASE_64_DATA..."
successful operation
bad request
GET /api/command/downloadImage HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "downloadImage",
"reply": "downloadImage",
"success": true
}
}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Encode an image file from the local filesystem into a data url.
Full path to the image file
successful operation
bad request
GET /api/command/encodeImage HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "encodeImage",
"reply": "encodeImage",
"success": true
}
}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Gets a list of all entries in the specified directory..
optional id to track this command, will be returned in the response
Full file path. Also see openFileDialog.
successful operation
bad request
GET /api/command/getDirectoryContent HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "getDirectoryContent",
"directory": "",
"reply": "getDirectoryContent",
"success": true
}
}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Read a file or url and return its data - especially useful when polling files for data..
optional id to track this command, will be returned in the response
Full file path. Also see openFileDialog.
Url to fetch.
Comma-separated string. Applies multiple parse methods to the data. Options: b64 (returns b64 encoded raw data), text (returns utf-8 encoded string), table (uses our csv, xml, json, Excel, db parser to extract tabular data), json (expects the file content to be XML or json, parses it, and returns a JavaScript object)
boolean value, if true, the data will be flattened into 1 level deep simplified object of key-value pairs.
successful operation
bad request
GET /api/command/getFileContent HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "getFileContent",
"reply": "getFileContent",
"success": true
}
}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Open a file browser to select a directory and return its full path along with its file contents..
optional id to track this command, will be returned in the response
Message for the title bar
Select A DirectoryOptional, folder to search
successful operation
bad request
GET /api/command/openDirectoryDialog HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Open a file browser to select a file and return its full path..
optional id to track this command, will be returned in the response
Message for the title bar (does not work on all platforms)
Select A FileOptional, folder to search
Set to true/1 to allow multiple file selection, response will include a filePaths array instead of the filePath string
1File format to look for, ie 'Images (*.png *.jpg .jpeg);;XML files (.xml)'. Multiple patterns are separated by ';;'.
Images (*.png *.jpg *.jpeg);;XML files (*.xml)successful operation
bad request
GET /api/command/openFileDialog HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Open a url in the system browser..
optional id to track this command, will be returned in the response
Url to open
https://newbluefx.comsuccessful operation
bad request
GET /api/command/openUrl HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "openUrl",
"reply": "openUrl",
"success": true
}
}API access: Full API Access (Enterprise, or Broadcast with the Full API Access add-on), on every connection.
Write the supplied data to a file..
optional id to track this command, will be returned in the response
Data to write to the file
Full file path. If omitted, will trigger the save dialog to open.
Set to 1 if the content is binary data.
Optional, default name for the save dialog.
Optional, user context to pass back in the notification.
successful operation
bad request
GET /api/command/setFileContent HTTP/1.1
Host: 127.0.0.1:9022
Accept: */*
{
"result": {
"command": "setFileContent",
"error": "Content size is 0",
"reply": "setFileContent",
"setFileContentRequest": "SFCREQ_1",
"success": true,
"userContext": ""
}
}Note: The
fetchUrlcommand exists to let you perform web requests when your controller is running in a browser context. Browsers have different security models that can sometimes limit your ability to get data from a remote resource.
Last updated