File Tools

Most of the file commands in Captivate can also take a url parameter to download the file from an online resource.

runDbQuery

get
/api/command/runDbQuery

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.

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

filePathstringOptional

Full file path. Also see openFileDialog.

tablestringOptional

If provided, will return the full content of the table using the same parsing as used by getFileContent.

sqlstringOptional

SQL query to run against the database.

Responses
chevron-right
200

successful operation

application/json
get
/api/command/runDbQuery

convertToJson

get
/api/command/convertToJson

Takes a supplied string of structured data (xml, csv, other json) and converts it to a JSON object..

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

contentstringOptional

String contents that should be parsed and converted.

Example: <item><child name="hello">world</child></item>
typestringOptional

type of the input string (xml, csv, json)

Example: xml
flattennumberOptional

boolean value, if true, the data will be flattened into 1 level deep simplified object of key-value pairs.

Example: 1
Responses
chevron-right
200

successful operation

application/json
get
/api/command/convertToJson

fetchUrl

get
/api/command/fetchUrl

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.

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

urlstringRequired

Url to fetch.

Example: https://newbluefx.com
methodstringOptional

HTTP method to use (GET, POST, PUT, DELETE, etc). Default is GET.

headersstringOptional

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.

bodystringOptional

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.

Responses
chevron-right
200

successful operation

application/json
get
/api/command/fetchUrl

downloadImage

get
/api/command/downloadImage

Download an image file from the Internet or parse it from a data url and save it to a local temporary file..

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

urlstringOptional

Optional: Full url to the image file

datastringOptional

Optional: a "data url" construct like "data:image/jpeg;base64,BASE_64_DATA..."

Responses
chevron-right
200

successful operation

application/json
get
/api/command/downloadImage

encodeImage

get
/api/command/encodeImage

Encode an image file from the local filesystem into a data url.

Query parameters
filestringOptional

Full path to the image file

Responses
chevron-right
200

successful operation

application/json
get
/api/command/encodeImage

getDirectoryContent

get
/api/command/getDirectoryContent

Gets a list of all entries in the specified directory..

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

dirPathstringOptional

Full file path. Also see openFileDialog.

Responses
chevron-right
200

successful operation

application/json
get
/api/command/getDirectoryContent

getFileContent

get
/api/command/getFileContent

Read a file or url and return its data - especially useful when polling files for data..

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

filePathstringOptional

Full file path. Also see openFileDialog.

urlstringOptional

Url to fetch.

parseMethodsstringOptional

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)

flattenstringOptional

boolean value, if true, the data will be flattened into 1 level deep simplified object of key-value pairs.

Responses
chevron-right
200

successful operation

application/json
get
/api/command/getFileContent

openDirectoryDialog

get
/api/command/openDirectoryDialog

Open a file browser to select a directory and return its full path along with its file contents..

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

captionstringOptional

Message for the title bar

Example: Select A Directory
dirstringOptional

Optional, folder to search

Responses
chevron-right
200

successful operation

application/json
Responseobject
get
/api/command/openDirectoryDialog

openFileDialog

get
/api/command/openFileDialog

Open a file browser to select a file and return its full path..

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

captionstringOptional

Message for the title bar (does not work on all platforms)

Example: Select A File
dirstringOptional

Optional, folder to search

filterstringOptional

File format to look for, ie 'Images (*.png *.jpg .jpeg);;XML files (.xml)'. Multiple patterns are separated by ';;'.

Example: Images (*.png *.jpg *.jpeg);;XML files (*.xml)
Responses
chevron-right
200

successful operation

application/json
Responseobject
get
/api/command/openFileDialog

openUrl

get
/api/command/openUrl

Open a url in the system browser..

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

urlstringOptional

Url to open

Example: https://newbluefx.com
Responses
chevron-right
200

successful operation

application/json
get
/api/command/openUrl

setFileContent

get
/api/command/setFileContent

Write the supplied data to a file..

Query parameters
requestIdstringOptional

optional id to track this command, will be returned in the response

contentstringOptional

Data to write to the file

filePathstringOptional

Full file path. If omitted, will trigger the save dialog to open.

hasBinaryContentstringOptional

Set to 1 if the content is binary data.

defaultnamestringOptional

Optional, default name for the save dialog.

userContextstringOptional

Optional, user context to pass back in the notification.

Responses
chevron-right
200

successful operation

application/json
get
/api/command/setFileContent

Note: The fetchUrl command 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