# Send Data by Using a POST Method

You can send files and binary data directly to Media Server using a POST request. One possible way to send a POST request over a socket to Media Server is using the cURL command-line tool.

The data that you send in a POST request must adhere to specific formatting requirements. You can send only the following content types in a POST request to Media Server:

- `application/x-www-form-urlencoded`
- `multipart/form-data`

TIP: Media Server rejects POST requests larger than the size specified by the configuration parameter `MaxFileUploadSize`.

## Application/x-www-form-urlencoded

The `application/x-www-form-urlencoded` content type describes form data that is sent in a single block in the HTTP message body. Unlike the query part of the URL in a GET request, the length of the data is unrestricted. However, Media Server rejects requests that exceed the size specified by the configuration parameter `MaxFileUploadSize`.

This content type is inefficient for sending large quantities of binary data or text containing non-ASCII characters, and does not allow you to upload files. For these purposes, Micro Focus recommends sending data as `multipart/form-data` (see Multipart/form-data).

In the request:

- Separate each parameter from its value with an equals symbol (`=`).
- Separate multiple values with a comma (`,`).
- Separate each parameter-value pair with an ampersand (`&`).
- Base-64 encode any binary data.
- URL encode all non-alphanumeric characters, including those in base-64 encoded data.

Example

The following example base-64 encodes the file `image.jpg` into a file `imagedata.dat` and sends it (using cURL) as `application/x-www-form-urlencoded` data to Media Server located on the `localhost`, using port `14000`. The example action adds the image to a new face in an existing face database named `politicians`.

1. Base-64 encode the image.

   - On Windows, create a Powershell script called `base64encode.ps1` that contains the following:

         Param([String]$path)
         [convert]::ToBase64String((get-content $path -encoding byte))

     Then from the command line, run the script using Powershell:

         powershell.exe base64encode.ps1 image.jpg > imagedata.dat

   - On Linux:

         base64 -w 0 image.jpg > imagedata.dat

2. Send the request to Media Server:

       curl http://localhost:14000
          -d 'action=TrainFace&database=politicians&identifier=president'
          --data-urlencode imagedata@imagedata.dat

You can send multiple images in a single request by separating the binary data for each image by a comma (in `imagedata.dat`).

## Multipart/form-data

In the `multipart/form-data` content type, the HTTP message body is divided into parts, each containing a discrete section of data.

Each message part requires a header containing information about the data in the part. Each part can contain a different content type; for example, `text/plain`, `image/png`, `image/gif`, or `multipart/mixed`. If a parameter specifies multiple files, you must specify the `multipart/mixed` content type in the part header.

Encoding is optional for each message part. The message part header must specify any encoding other than the default (7BIT).

Multipart/form-data is ideal for sending non-ASCII or binary data, and is the only content type that allows you to upload files. For more information about form data, see http://www.w3.org/TR/html401/interact/forms.html.

NOTE: In cURL, you specify each message part using the `-F` (or `--form`) option. To upload a file in a message part, prefix the file name with the `@` symbol. For more information on cURL syntax, see the cURL documentation.

Example

The following example sends `image.jpg` (using cURL) as `multipart/form-data` to Media Server located on the `localhost`, using port `14000`. The example action adds the image to a new face in an existing face database named `politicians`.

    curl http://localhost:14000 -F action=TrainFace
                                –F database=politicians
                                –F identifier=president
                                –F imagedata=@image.jpg

© Copyright 2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm