Send Data by Using a POST Method
You can send files and binary data directly to Eduction using a POST request. One possible way to send a POST request over a socket to Eduction is using the cURL command-line tool.
The data that you send in a POST request must adhere to specific formatting requirements. You must use one of the following content types:
application/x-www-form-urlencoded
multipart/form-data
TIP: Eduction 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, Eduction 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. For these purposes, OpenText recommends sending data as 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 uses the command-line tool curl
to send an application/x-www-form-urlencoded
request to an IDOL Content component. This query finds documents that are conceptually similar to some query text.
curl http://content:9100/action=SuggestOnText --data-urlencode "Text=common uses of the ampersand (&) character" --data-urlencode Print=Reference
multipart/form-data
OpenText recommends using multipart/form-data
for sending non-ASCII or binary data. With this 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).
NOTE: With 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 about using cURL, refer to the cURL documentation.
Example
The following example uses the command-line tool curl
to send a multipart/form-data
request to an IDOL Media Server. This request includes two files: a configuration file for performing Optical Character Recognition, and an image file to analyze.
curl http://mediaserver:14000/action=Process -F config=@ocr.cfg -F sourcedata=@image.tiff