# Genesys Quality Management Suite 8.1.520 : Examples

Created and last modified by

The following examples use both a Web browser (in this case Firefox), and the command line tool cURL, an open source tool available for all major operating systems.

Replace strings shown between angle brackets (for example: `<server>, <username>, <password>`) with appropriate values (such as: `http://callrec.company.com, admin, mypassword`).

## Log In To Call Recording

With Firefox:

To log into Call Recording, point to this address:

    http://<server>/callrec/loginservlet?loginname=<
    username>&password=<password>

The Service will reply with a response similar to the following:

    <ok sessionid="BA803B97624F0880A4C58B78C733EB5B" number="1">Access is authorized.</ok>

Note that the reply includes a `JSESSIONID` value. It will be needed later for the other services.

With cURL:

    curl -v -b cookies.txt -c cookies.txt -X POST -d "loginname=<username>" -d "password=<password>" \ -H"Content-Type: application/x-www-form-urlencoded" -H"Accept: text/plain" http://<server>/callrec/loginservlet

The service will reply with a `JSESSIONID` (present both in the XML response and the created `cookies.txt` cookie file). This is required later for accessing the other services:

    * 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/loginservlet 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
    > Content-Type: application/x-www-form-urlencoded
    > Accept: text/plain
    > Content-Length: 33
    > < HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
    * Added cookie JSESSIONID="E3D794FEE4638143C1C89C18F693EB6B" for domain myserver, path /callrec, expire 0
    < Set-Cookie: JSESSIONID=E3D794FEE4638143C1C89C18F693EB6B; Path=/callrec
    < Transfer-Encoding: chunked
    < Date: Fri, 20 May 2011 10:10:18 GMT
    < <?xml version="1.0" encoding="UTF-8"?> <ok sessionid="E3D794FEE4638143C1C89C18F693EB6B" number="1">Access is authorized.</ok>
    * Connection #0 to host myserver left intact
    * Closing connection #0

A `cookies.txt` file will be created with the following content:

    # Netscape HTTP Cookie File
    # http://curl.haxx.se/rfc/cookie_spec.html
    # This file was generated by libcurl! Edit at your own risk. myserver	FALSE	/callrec	FALSE	0 JSESSIONID	E3D794FEE4638143C1C89C18F693EB6B

See the description of the Log In Service for more details.

### Request a Media File with the Audio Data Service

The following sample search criteria will be used for this request:

- `timeLength: 10 seconds`
- `callingParty: 5655`
- `problemStatus: NO_PROBLEM`
- `startTime: 2011-05-20 12:14:14.684`

With Firefox:

Enter the following URL into the browser, including the `JSESSIONID` value obtained in the previous request and the above search criteria (the \ characters represents line breaks that should be removed and the complete URL pasted in one line):

    http://<server>/callrec/audiodata;jsessionid=<jsessionid>\
    ?startTime=2011-05-20%2012:14:14.684&problemStatus=NO_PROBLEM\
    &callingParty=5655&timeLength=10

The server will respond by sending the media file, triggering the browser to display the file open/save dialog.

With cURL:

Use the following command, specifying the location of the `cookies.txt` cookie file obtained in the previous request together with the sample search criteria:

    curl -v -b cookies.txt -c cookies.txt -X POST -d "startTime=2011-05-20%2012:14:14.684" -d \
    "problemStatus=NO_PROBLEM" -d "callingParty=5655" -d "timeLength=10" \
    -H"Content-Type: application/x-www-form-urlencoded" -H"Accept: application/octet-stream" \
    -o media.mp3 http://<server>/callrec/audiodata

The server will respond by sending the requested media file:

    * About to connect() to myserver port 80 (#0)
    * Trying 10.0.0.1... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0connected
    * Connected to myserver (10.0.0.1) port 80 (#0)
    > POST /callrec/audiodata 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: application/octet-stream
    > Content-Length: 26
    > } [data not shown] 0 0 0 0 0 26 0 0 --:--:-- 0:01:01 --:--:-- 0< HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
    < Content-Disposition: attachment; filename=1305886454684_5655_5682_29.mp3
    < Content-Type: application/octet-stream;;charset=UTF-8
    < Content-Length: 29936
    < Date: Fri, 20 May 2011 10:28:46 GMT
    < { [data not shown]
    100 29936 100 29936 0 26 468 0 0:01:03 0:01:03 --:--:-- 7875
    * Connection #0 to host myserver left intact
    * Closing connection #0

If multiple audio files meet the search criteria specified, the server will respond with an error similar to the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <error sessionid="5DFF7181E7CF8C9B76F33418D2BBFFBA" number="5">
    Multiple results found.</error>

See the description of the Audio Data Service for more details about valid search parameters.

### Request a Download Token

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

See the description of the Download Token Service for more details.

### Request a Media File with the Send Call File Service

Now that we have the download token, the Send Call File Service can be called:

With Firefox:

Enter the following URL into the browser to invoke the Send Call File Service (substituting in the download token obtained):

    http://<server>/callrec/sendcallfile.mp3;jsessionid=<
    jsessionid>?token=<download_token>

The server will respond by sending a zip containing the requested media files, triggering the browser to display the file open/save dialog.

With cURL:

Invoke the Send Call Service with the following request:

    curl -v -b cookies.txt -c cookies.txt -X POST -d "token=<download_token>" \
    -H"Content-Type: application/x-www-form-urlencoded" -H"Accept: application/octet-stream" \
    -o file.zip http://<server>/callrec/sendcallfile.mp3

The server will respond with a zip containing the requested media files:

    * About to connect() to myserver port 80 (#0)
    * Trying 10.0.0.1... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0connected
    * Connected to myserver (10.0.0.1) port 80 (#0)
    > POST /callrec/sendcallfile.mp3 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=8A355EC61B5D804447704B8CB64DF535
    > Content-Type: application/x-www-form-urlencoded
    > Accept: application/octet-stream
    > Content-Length: 26
    > } [data not shown]
    < HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
    < Content-Disposition: attachment; filename=calldata.zip
    < Content-Type: application/zip;
    < Transfer-Encoding: chunked
    < Date: Fri, 20 May 2011 13:55:18 GMT
    < { [data not shown]
    100 40521 0 40521 0 26 440k 289 --:--:-- --:--:-- --:--:-- 454k
    * Connection #0 to host myserver left intact
    * Closing connection #0

See the description of the Send Call File Service for more details about valid search parameters.

### Request a Log File with the Send Log File Service

With Firefox:

Enter the following URL into the browser to download the audit log file, after first logging in using the Log In Service step above:

    http://<server>/callrec/sendlogfile?sendLogIdx=1

The server will respond by sending the log file in a zip, triggering the browser to display the file open/save dialog.

With cURL:

Use the following command, after first completing the Log In Service step above:

    curl -v -b cookies.txt -c cookies.txt -X POST -d "sendLogIdx=1" -H"Content-Type: application/x-www-form-urlencoded" \ -H"Accept: application/octet-stream" -o audit-log.zip http://<server>/callrec/sendlogfile

The server will respond by sending the log file in a zip:

    * About to connect() to myserver port 80 (#0)
    * Trying 10.0.0.1... % Total % Received % Xferd Average Speed Ti
    me Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0co
    nnected
    * Connected to myserver (10.0.0.1) port 80 (#0)
    > POST /callrec/sendlogfile 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=8A355EC61B5D804447704B8CB64DF535
    > Accept: */*
    > Content-Length: 12
    > Content-Type: application/x-www-form-urlencoded
    >
    } [data not shown]
    < HTTP/1.1 200 OK
    < Server: Apache-Coyote/1.1
    < Content-Disposition: attachment; filename=audit_log.zip
    < Content-Type: application/zip;
    < Transfer-Encoding: chunked
    < Date: Wed, 15 Jun 2011 13:46:56 GMT
    <
    { [data not shown]
    100 301k 0 301k 0 12 644k 25 --:--:-- --:--:-- --:--:-- 666k
    * Connection #0 to host myserver left intact
    * Closing connection #0

See the description of the Send Log File Service for more details about log file IDs.