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.
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: Thepswd
value should be the encrypted password returned from thelogin
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 (exceptlogin
). 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: Ifkill=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
.
Query string example
https://www2.1010data.com/gw.k?api=savefile&apiversion=3&uid=$UID&pswd=$PSWD&sid=$SID
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 attributetype
andtype
may have one of the following values:headers
- Column headersnames
- Column namesformatted
- Formats the values in the appropriate output type, instead of presenting the raw value
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)<compression>
- The type of compression used to save the file. Options arezip
(the default value),gzip
, andraw_gzip
.
If not specified, the column separator is a comma, and the line separator is newline (
). <target>
- Saves the file to an external storage location.
<target>
must contain one of the following child elements:file
- Saves the file to the user's ftp folder (same as<file>
element)s3
- Saves the file to Amazon S3 storage.abs
- Saves the file to Azure blob storage.
Note: In order to uses3
orabs
, the user must have saved their storage account key to their platform account with theaddkey
transaction.Each storage option has one of the following
format
attributes:txt
(the default value),csv
,xlsx
,pdf
,tde
,data
, andparquet
.
Either <file>
or <target>
is required; the others
elements are optional.
<target>
examples
<target><file>filename</file></target>
<target><s3 api_key="mykey" bucket="xxxxxx" format="xlsx">filename</s3></target>
<target>
<abs api_key="mykey" storage_account_name="xxxxxx" container="yyyyyy">filename.csv
</abs>
</target>
XML input examples
<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>