# Genesys Quality Management Suite 8.1.520 : Audio Data Service

The Audio Data Service can be used to request a single audio data file from the server. The user needs to be logged in and authorized for the audio file requested, however a download token is not required in order to retrieve files.

### Service Pre-requisites

The service requires:

- The `JSESSIONID` obtained from the Log In Service
- Search criteria for calls provided as input parameters

### Service Invocation

An HTTP POST method must be addressed to the following URL:

    http://<server>/callrec/audiodata

### Input Parameters

The service expects to receive:

- The previously obtained `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>`

### Input Parameters

When requesting audio data, search criteria must be specified. The Audio Data Service accepts one or more of the following search parameters:

Parameter Name | Description | Format | Notes
--- | --- | --- | ---
`callingPartyName` | Name of the user who initiated the call | String | The String must be URL encoded (for example: `%20` for spaces).
`calledPartyName` | Name of the destination user | String | The String must be URL encoded (for example: `%20` for spaces).
`callingParty` | Phone extension of the user that initiated the call | Integer |
`calledParty` | Phone extension of the destination user | Integer |
`coupleType` | The type of couple depends on the kind of call; for example a normal call or a conference call. | String | Valid values are: `NORMAL, CONFERENCE, RECONN, PARK, UNPARK, BARGE.`
`problemStatus` | Specifies problems with the couple (if any), such as not having any audio streams or no problems found. | String | Valid values are: `NO_PROBLEM, ALL_STREAM_DELETED, STILL_SAVING_STREAM, ONLY_ONE_STREAM, STREAM_IS_NULL, NO_STREAMS.`
`callingIpAddress` | IP address that initiated the call (source). | IP Address |
`calledIpAddress` | Destination IP address | IP Address |
`b_method` | Used for synchronization purposes. | String | Possible values are: `TAPE, DISK_A, DISK_N, ARC`.
`b_location` | Used for synchronization purposes. | String | The path where the archive is stored.
`dbId` | The value of the column ID from the couple table in the database. | Integer |
`dbIdParentCall` | Value of the callid column in the database couple table. | Integer | A call can be split into multiple copies. To identify them, all couples reference the parent call that they belong to.
`startTime` | The start time of the call. | yyyy-MM-dd HH:mm:ss.SSS | The String must be URL encoded (for example: `%20` for spaces).
`stopTime` | The end time of the call. | yyyy-MM-dd HH:mm:ss.SSS | The String must be URL encoded (for example: `%20` for spaces).
`timeLength` | Duration of the call. Expressed in seconds. | Number (integer) |
`externalData` | External data attached to a call such as user ID or call metadata. | String. Many values can be sent at once. The format is: <external_key>`$!$`<external_value> | These values depend on the configuration. The most commons ones are: `CALLED_STREAM_PAYLOAD, CALLED_URL, CALLING_STREAM_PAYLOAD, CALLING_URL, COUPLE_END_REASON, COUPLE_START_REASON, GROUP_ID, JTAPI_CALLED_TERMINAL_SEP, JTAPI_CALLING_TERMINAL_SEP, JTAPI_CISCO_CALLMANAGER_ID, JTAPI_CISCO_GLOBAL_CALL_ID, JTAPI_CISCO_ID, SPANLESS_CALLED_REC_ID, SPANLESS_CALLING_REC_ID, SPANLESS_REC_ID, SPANLESS_REC_INFO.`

### Output

The service will return:

- An HTTP status
  - This status can be: `200 OK:` always returned

- A body response
  - The response will be sent as `text/xml`, and will include details about the operation; for example: problem with connection
- The actual media file returned as `application/octet-stream`, if the operation was successful

Important:This status will be sent in all cases, including when the parameters are correct, incorrect, or when the request is malformed.
The service expects the search criteria to identify a single audio file. If multiple audio files meet the search criteria, then no audio file will be returned, and the body response will return the list of couple IDs. The maximum size of this list is 1000.

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

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.

###