Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter TwelveInternet Functions (continued)

HTTPPost Function

Overview

The HTTPPost function posts multiple part data to a server and retrieves a string with the reply page. The function uses the ‘post’ HTTP verb and uses form encoded or multi-part form depending on whether a file is included in the data.

Syntax/Parameters

Syntax

string = HTTPPost ( [handle hHTTP], string uri, string params[],
                [handle hFile | string filename], [handle hResponse] );

Parameters

hHTTP

An optional handle specifying an existing HTTP connection to employ for the transaction. If a handle is used, the HTTP type and authority (domain) must match for the supplied uri parameter.

uri

A string as a valid URI (which must contain the scheme HTTP or HTTPS) or a path with an optional query. The URI can contain query information but cannot contain multi-part requests (POST type HTTP). The uri can contain just the path and an optional query when an HTTP connection handle is used.

params

A string array containing key names and data. The key names become the query names and the array value the query data. Each parameter is limited by the key name size with the data limited to approximately 20kb. The total number of parameters is not limited. If each array entry does not have a key name, an error will be returned.

hFile  or  filename

An optional file specification as either a Basic File Object handle or a qualified filename string. When provided, the params array must contain an entry with the data set to ‘%%FileData%%’ which is used to substitute the file data for that named parameter.

hResponse

An optional handle value for a File Object to receive the response data. If this parameter is used, the hFile or filename parameter must be provided, they can be NULL_HANDLE or "" respectively.

Return Value

A string containing the reply data. On error the string will be empty. Use the GetLastError function to get the formatted error code or the HTTP response code and GetLastErrorMessage to return details of the error.

If a response file is provided, the string will contain “(response in file)”.

Note that a non-empty string does not indicate success. If the post reaches a server and the page is not found or the parameters are incorrect, the server may respond with an error page returned as the string.

Remarks

The HTTPPost function makes a server request using the multiple part “post” method to the host server. It allows for the transmission of file data as one of the parameters.

Reply or response data can be captured in string form or in the form of a file. If the data may exceed 2MB, a file should be employed.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic