savefile (Save query results as a file)

The savefile transaction saves the results of a query as a file in your 1010data FTP folder. The file can then be downloaded via FTP.

Note: To use this transaction, you must be authorized for FTP downloads.

Query string

The query string in the HTTP header must contain the following parameters:

api
Specify the name of the API transaction.
apiversion
Specify the version of the API that should handle the requested transaction.

For the most up-to-date version, use apiversion=3.

uid
Specify a valid 1010data user name.
pswd
Specify a valid password for the 1010data user name provided to the uid parameter.
Note: The pswd value should be the encrypted password returned from the login transaction.
sid
The session ID for the current API session.

This value is returned by the login transaction and must be provided to every transaction (except login).

kill (optional)
Valid values for kill are as follows:
yes
Terminate the existing session and start a new one.
no
Do not terminate the existing session.

If no session exists, a new one will be created. If a session does exist, an error is returned.

Note: If kill=no and a session is active, the system returns an error.
possess
Log in and possess the existing session.
auth
Authenticate with the system but do not kill, possess, or start any session.

The default is yes.

XML Input to Server

The specifications must contain the following elements:

<file>
The name of the result file

If a file already exists with that name, it will be replaced.

<content>
The meta information to include in the file (optional)

<content> must contain one or more <meta> elements, each identifying one type of information.

Each <meta> element must include attribute type and type may have one of the following values:
  • headers - Column headers
  • names - Column names

If not specified, no meta information is included in the file.

<format>
The data format for the result (optional)
<format> has no attributes and may contain the following elements:
  • <sep> - Character with which to separate fields (columns)
  • <linesep> - Character with which to separate records (rows)

If not specified, the column separator is a comma, and the line separator is newline ( &#10;).

<file> is required; the others are optional.

Query string example

https://www2.1010data.com/gw.k?api=savefile&apiversion=3&uid=$UID&pswd=$PSWD&sid=$SID

XML input example

<in>
<file>My File</file>
<content>
   <meta type="names"/>
</content>
<format>
   <sep>,</sep>
</format>
</in>

XML response from server

A successful savefile contains the following elements:

<rc>
The return code generated by the transaction. For a list of return codes, see Return codes.
<msg>
The message returned by the system. Specific messages correspond to specific return codes.

XML response example

<out>
  <rc>0</rc>
  <msg>Saved file My File</msg>
</out>