# Genesys Quality Management Suite 8.1.520 : Download Token Service

The Download Token Service creates a download token used for one-time requests for restricted resources, like call files. A token holds all parameters required for obtaining the resource, and the following restrictions apply:

- The token can be used only once and is discarded after use.
- A download token's lifetime is limited by the user's session lifetime.

Service Pre-requisites | The service requires the `JSESSIONID` obtained in the Log In Service.
Service Invocation | A GET or POST HTTP method must be addressed to the following URL:
    http://<server>/callrec/downloadtoken
Input Parameters | The service expects to receive: A `JSESSIONID` to identify the user in the form of: A cookie An append to the URL immediately after the servlet name, as follows: `jsessionid=<sessionid>` Search criteria used to identify audio files (Send Call File Service only) More than one criteria parameter can be used at the same time Parameters are dependent on the service used afterwards (check the service description for more details) All parameters for the search criteria must be sent in the format: `application/x-www-form-urlencoded`
Output | The service will return: An HTTP status This status can be: `200 OK:` always returned A body response including the download token if the operation was successful The response will be sent as `text/xml`, and the token will be included inside the tag `<reply>` This status will be sent in all cases, including when the parameters are correct, incorrect, or when the request is malformed.
Sequence Diagram | The following diagram illustrates the use of the Download Token Service during an operation to download call media files using the Send Call File Service.

### Request a Download Token example

The download token is required before requesting a media file from the Send Call File Service.

For this example, the following search criteria will be specified:

- `id_call[]: 1165, 1166`
- `type: 1`
- `action: download`

With Firefox:

Enter the following URL into the browser:

    http://<server>/callrec/downloadtoken;jsessionid=<jsessionid>?id_call[]=1165,1166&type=1&action=download

The server will respond with a token similar to the following:

    <reply>NWnMJ4iKhVLOY0sUlGDX</reply>

With cURL:

Use the following command:

    curl -v -b cookies.txt -c cookies.txt -X POST -d "id_call[]=1165,1166" -d "type=1" -d "action=download" \
    -H"Content-Type: application/x-www-form-urlencoded" -H"Accept: text/xml" http://<server>/callrec/downloadtoken

The server will respond with a token similar to the following:

    * About to connect() to myserver port 80 (#0)
    * Trying 10.0.0.1... connected
    * Connected to myserver (10.0.0.1) port 80 (#0)
    > POST /callrec/downloadtoken HTTP/1.1
    > User-Agent: curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
    > Host: myserver
    > Cookie: JSESSIONID=E3D794FEE4638143C1C89C18F693EB6B
    > Content-Type: application/x-www-form-urlencoded
    > Accept: text/xml
    > Content-Length: 92
    > < HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
    < Transfer-Encoding: chunked
    < Date: Fri, 20 May 2011 10:27:30 GMT
    < <?xml version="1.0" encoding="UTF-8"?> <reply>y1vqe7xvFffKA1R5xgS6</reply>
    * Connection #0 to host myserver left intact
    * Closing connection #0