Create

This API creates a media file object to be stored in the CVP Media Servers.

  • If no serverlist is specified, the media file object is created on all the media servers.

  • If the operation fails on some servers but not on all servers, the file is created on the server where the operation is successful. The user needs to do a PUT operation on the failed servers to ensure that the file is deployed on all.

  • If the media file object already exists, the create operation will fail with a “400 Bad Request” error. The user should use a PUT operation instead to update the existing object.

For this API, a 200 OK response will be returned on the successful creation of the media file object in the management database, but the media files will be copied to the media servers. Use the READ (GET) API to poll for the copying status on the individual servers.

To obtain only the summary details, the summary=true flag is used in the GET API.

  • When the create operation is still in progress, the status of the object is shown as creating.

  • If the operation is completed on all servers, the status of the object will be shown as created and errorflag as false.

  • If the requested operation cannot be completed due to some error, the status of the object is shown as created but the errorflag is shown as true. The details of the errors can be obtained using the GET API without the summary parameter to provide a server-wise status description.

Parameters of Media File - Create

URL

https://<ipaddress>:8111/cvp-config /mediafile

HTTP Method

POST

API Type

Synchronous

Input Format

multipart/form-data

Output Format

JSON/XML

Parameters

The parameters should be passed as multipart/form-data contents, with the text parameters in a JSON/XML part followed by the binary data as a separate part.

Name: path

Description: Text parameter containing the relative path in the media location.

Required: Yes.

Values: Relative path names. For example: en-us/app as used by the application.

Validations: Should not contain any (.) or should not be an absolute path.

Notes: Passed in XML/JSON body.

Name: filename

Description: Text parameter containing the media file name.

Required: Yes.

Values: String values with less than 100 characters.

Validations: Should not contain special characters like "~", >, <.

Notes: Passed in XML/JSON body.

Name: servers

Description: List of server reference URLs.

Required: No.

Values: Contains multiple <server> elements.

Notes: Optional parameter containing the server ref list, passed in XML/JSON body.

Name: server

Description: Reference of individual Unified CVP media server.

Required: No.

Values: As depicted in CVP Servers section.

Notes: Optional parameter containing the server ref, passed in XML/JSON body.

Name: file

Description: This file will be uploaded.

Required: Yes.

Values: Multipart form posts as handled by the FORM POST method.

Validations: Size of individual file should not exceed MAX_FILE_SIZE (3MB).

Notes: Need to be appended by either browser after FORM POST is run or by equivalent code, if done programmatically.

Example Request Payload

This server list body is passed as the first part of multipart/form-data. The WAV file that contains the media content is attached as the second part.

Key

Sample Value

mediaUploadConfig

XML
Code Snippet
Copy
<mediafile>
	<path>en-us</path>
	<filename>agentgreeting.wav</filename>
	<servers>
		<server>ref-url of server1</server>
		<server>ref-url of server2</server>
	</servers>
</mediafile>
JSON
Code Snippet
Copy
{
	"mediafile": {
		"path": "en-us",
			"filename": "agentgreeting.wav",
		"servers": {
			"server": [
				"ref-url of server1",
				"ref-url of server2"
			]
		}
	}
}

mediafile

The WAV file that contains the media content.

Code Snippets

Sample Java Code

Code Snippet
Copy
/**
 * Creates the media file in the servers.
 * The request has two parts.
 * 1. mediaUploadConfig - The configuration file containing the filename, 
path and server details.
 * 2. mediafile - The octet stream of the file attached.
 */

private static void createMediafileRequest() {
	Client client = getSSLClient();
	ClientFilter authFilter = new HTTPBasicAuthFilter
("wsmadmin","<password set during installation>");
	client.addFilter(authFilter);

	WebResource webResource = null;
	webResource = client.resource("https://<OAMP IP Address>:8111/cvp-config");

	// Populate config for Media File and convert it into JSON/XML
	MediaUploadConfig config = populateConfig();
	String requestString = convertToJson(config);

	// Construct a MultiPart with two body parts
	byte mediaContent[] = readFile();
	FormDataMultiPart formPart = new FormDataMultiPart();
	formPart.field("mediafile", mediaContent, MediaType.APPLICATION_OCTET_STREAM_TYPE);
	formPart.field("mediaUploadConfig", requestString, MediaType.APPLICATION_XML_TYPE);

	// POST the request
	ClientResponse clientResponse = webResource.path("/mediafile").
accept(MediaType.APPLICATION_XML_TYPE).type(MediaType.MULTIPART_FORM_DATA).
post(ClientResponse.class, formPart);
}

Sample Response Header

Code Snippet
Copy
Response HTTP Status : 200
Response Headers : {Date=[Mon, 01 Apr 2013 21:11:53 GMT], Content-Length=[0], 
Content-Type=[application/xml;charset=utf-8], Server=[Apache-Coyote/1.1]
}
Media File CREATE Error Messages

Category

HTTP Status

Error Code

Error Description

Error data

Error Detail

Authentication

401

authorization.unathorized

Unauthorized request

NA

NA

Authentication

401

authentication.notAuthorized

User is not authorized to access the requested resource

NA

NA

Authentication

401

authentication.noAccess

User is not allowed to access the resource. Check the user roles

NA

NA

Input Output Formatting

400

processing.jsonSyntaxError

JSON syntax error while processing the request attachement

NA

NA

Input Output Formatting

400

processing.xmlSyntaxError

XML Syntax error while processing the request attachement

NA

NA

CREATE Media file Validation

400

invalid.noOfAttachments

Incorrect number of attachments received

NA

NA

CREATE Media file Validation

400

invalid.format

URL cannot be decoded using UTF-8

NA

NA

CREATE Media file Validation

400

invalid.inputUploadConfig

Input xml/json is empty

NA

NA

CREATE Media file Validation

400

invalid.inputMediaFile

Input media file missing

NA

NA

CREATE Media file Validation

400

invalid.requestAttachment

Malformed JSON in request attachment

NA

NA

CREATE Media file Validation

400

invalid.attachment

Request attachment IO Error

NA

NA

CREATE Media file Validation

400

invalidInput.invalidCharacter

Invalid characters in the input field

Field Name which has invalid characters

InvalidValueErrorDetail

CREATE Media file Validation

400

invalidInput.invalidFieldLength

Invalid length of input field

Field Name which has invalid length

StringLengthErrorDetail

CREATE Media file Validation

400

invalidInput.invalidMediaServerRef

Invalid Media Server Ref URL

serverRef

InvalidValueErrorDetail

CREATE Media file Validation

400

invalidInput.invalidMediaFileExtension

Invalid Media File Extension

fileName

InvalidValueErrorDetail

CREATE Media file Validation

400

invalidInput.requiredInputfieldMissing

Required Input Field is missing

Missing Required Input field

RequiredFieldErrorDetail

CREATE Media file Validation

400

invalidInput.incompatibleServerVersion

Listed Media Server version is incompatible

serverRef

InvalidValueErrorDetail

CREATE Media file Validation

400

invalidInput.serverInformationNotAvailable

Listed server information not available

serverRef

InvalidValueErrorDetail

CREATE Media file Validation

400

invalidInput.invalidDirDepth

The Directory dept in the path field is greater than the maximum allowed

path

StringLengthErrorDetail

CREATE Media file Validation

400

invalidInput.duplicateServerRef

There is a duplicate entry in the Server list sent in the request

serverList

InvalidValueErrorDetail

CREATE Media file Validation

400

invalid.inputMediaFile

File Size out of valid range

NA

FileSizeErrorDetail

For more information on common error codes, see Unified CVP API Error Codes