Skip to content

HTTPPostAddrRequest - cBaseHTTPTransfer

Performs an HTTP POST request

Type: Function
Return Data Type: Integer

Parameters

Parameter Type Description
sFilePath string Path to perform the HTTP POST
aData address Memory address of the data to be posted
iDataLength Integer Number of bytes to post
bDataIsFile boolean If False, the value of aData is sent as HTTP POST body. If True, aData is interpreted as a filename and the contents of that file are sent as the POST body instead of the actual value of aData

Syntax

Function HTTPPostAddrRequest string sFilePath address aData Integer iDataLength boolean bDataIsFile Returns Integer

Call Example

Get HTTPPostAddrRequest sFilePath aData iDataLength bDataIsFile to IntegerVariable

Description

The HTTPPostAddrRequest function performs an HTTP POST request. All headers previously added using AddHeader, if any, are also sent as part of the request.

The OnDataReceived event is triggered for any response sent by RemoteHost.

This function is provided to allow the posting of large amounts of data (i.e., not limited to the maximum length of a DataFlex string). If you do not need to post large amounts of data you can use the simpler string-based function HttpPostRequest.

Sample

The following sample posts an XML document that is passed as an XML node. Since the length could be quite long, we use HttpPostAddrRequest method to do the post.

Function PostXmlNode String sHost String sFilePath Handle hoXmlNode returns Boolean
    Address aXmlNode aXml
    Integer iVoid iLen
    Boolean bOK
    Handle hoXml

    // write XML data to memory heap pointed to by aXMLNode
    Get paXml of hoXmlNode to aXmlNode

    // assume data from paXml is always zero terminated
    Move (Length(aXmlNode)) to iLen

    Set psRemoteHost to sHost

    Get AddHeader "CONTENT-TYPE" "text/xml" to bOK

    Get HttpPostAddrRequest sFilePath aXml iLen False to bOK

    Move (Free(aXmlNode)) to iVoid  // free memory

    Function_Return bOk
End_Function
Col 1 Col 2
Note: Note that the cXmlHttpTransfer class already provides the above functionality for you.

Return Value

Returns True if successful, and False otherwise