Open topic with navigation

# Send Data with a POST Method

You must send the `DREADDDATA` action using a POST request method. There are two ways to send a POST request over a socket to HPE IDOL Server:

- use the Curl command-line tool

- use a script

Note: You can use these methods for other actions that require a POST request method, such as `DREREPLACE`, but you must modify the script.

## Use the cURL Command-Line Tool

Curl is an open source command-line tool for transferring files with URL syntax. If you have cURL installed on your computer, and a command prompt that allows you to use new lines, you can use a cURL request to send the action. For example:

    curl "http://host:port/DREADDDATA?" -d "
    #DREREFERENCE Test
    #DREDBNAME Default
    #DREENDDOC
    #DREENDDATA
    "

Alternatively, you can add the `#DREENDDATA` tag into the IDX or XML document, or gzipped IDX or XML file, after the data to index. The `#DREENDDATA` tag must be uncompressed.Then you can use a cURL command to send this document to HPE IDOL Server.

For example:

    curl --data-binary @filename "http://host:port/DREADDDATA?"

where `filename` is the name of the IDX, XML, or gzipped IDX or XML file to index.

For information on cURL, refer to http://curl.haxx.se/.

## Use a Script

Another method of sending a POST request is to use a script to open a socket and send the data. The following is an example script in the Perl programming language that sends a `DREADDDATA` index action to a specified port.

To run the script

- Open a command prompt and type the following command:

    PerlScript.pl HostNameIndexPortFilename [Parameters]

where:

`PerlScript.pl` | is the name of the file that contains the Perl script that performs the `DREADDDATA` index action.
`HostName` | is the host name or IP address of the host on which the HPE IDOL Server runs.
`IndexPort` | is the index port for the HPE IDOL Server you send the data to.
`Filename` | is the name of the file that you index into HPE IDOL Server by using the `DREADDDATA` action. You can use an IDX, XML, or gzipped IDX or XML file.
`Parameters` | are any optional parameters that you use for the `DREADDDATA` action.

Example Perl Script

    # Performs a /DREADDDATA index action
    use IO::Socket;

    if (@ARGV<3)
    {
       print "Usage: doDreAddData.pl <hostname> <indexport> <filename> [parameters]\n";
       exit;
    }

    my $host = $ARGV[0];
    my $port = $ARGV[1];
    my $filename = $ARGV[2];
    my $params = $ARGV[3];
    my $footer = "\r\n#DREENDDATA\r\n\r\n";
    my $iaddr = inet_aton($host) or die "$!";
    my $paddr = sockaddr_in($port,$iaddr);
    my $proto = getprotobyname('tcp');

    socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
    connect(SOCK, $paddr) or die "connect: $!";

    my $filesize = -s $filename;
    $filesize += length($footer);
    open (FILE, $filename) or die "couldn't open file: $!";

    print SOCK "POST /DREADDDATA?$params HTTP/1.1\r\n";
    print SOCK "Connection: close\r\n";
    print SOCK "Content-Length: $filesize\r\n\r\n";
    while (<FILE>)
    {
       print SOCK $_;
    }
    print SOCK $footer;

    SOCK->autoflush(1);

    while(<SOCK>){
       print $_;
    }

    close FILE;
    close SOCK;

© 2016 Hewlett Packard Enterprise Development LP | Send documentation feedback to HPE Close Send Documentation Feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to AutonomyTPFeedback@hpe.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_HP_HTML5_bannerTitle.htm