Adds a POST key and value pair to be used in a POST operation with HTTPGet and HTTPGetEx().

POST data is the main mechanism that HTTP uses to send data from the client to the server. POST data typically gets encoded on the client and then sent up to the server. Several different mechanisms are available:

  • UrlEncoded Form Data (1)
  • Multi-Part Forms (2)
  • Raw Data (4)
    (you need to set the .cContentType property to specify type)

Web Connection supports all three conntent types through the nHTTPPostMode property setting. If you wish to post a raw or binary buffer you can simply pass a single parameter to AddPostKey with the value and it gets written as is.

HTTP File Uploads are supported via the tlFileName parameter which specifies a file to upload to the server. Make sure you use nHTTPPostMode=2 to specify multipart forms be created in the POST buffer.

o.AddPostKey(tcKey, tcValue, 
             tlIsFile, tcContentType, 

Return Value



The key value to set. One special value can also be used:

RESET - clears any existing POST data. No value is required to be passed in this case. If you call AddPostKey with no paramters at all the POST buffer is also cleared.

BLANK - ("" or omitted) if this value is empty or not provided tcValue will be used to write the entire POST buffer unencoded. Use for XML documents or anything where you need to post a raw POST buffer.

The value to set the key to. In combination these values are equivalent to a Form Variable name and value.

Multi-Part Forms specific parameters

If this value is set to .T. the second parameter is a filename on disk that is to be uploaded to the Server. NOTE: This only works if nHTTPPostMode = 2 otherwise this option is omitted.

Optional content type for the value in multi-part forms mode (2). Use this for files if you want to explicitly specify the content type. If left blank this value is not set.

Extra headers to add to multi-part form mode (2) submissions other than content type. Each header is a full HTTP header on an individual line followed by CHR(13) + CHR(10).

lcHeader = "Content-Length: 400" + CRLF +;
           "X-Custom-Header: Custom" + CRLF +;
           "X-Custom-Header2: Custom2"


UrlEncoded content that is longer than 254 characters requires wwIPStuff.dll for the URLEncoding using C++ code for better performance. This refers to the default nHttpPostMode value of 1.

Depending on the value of the nHTTPPostMode property forms are posted either in standard URLEncoded or Multi-Part form mode. Multi-part form mode can be more efficient for large uploads as no encoding takes place, but the server application must support parsing multi-part forms. Web Connection automatically handles this via Request.Form().



loHTTP.AddPostKey("Company","West Wind")
loHTTP.AddPostKey("Name","Rick Strahl")

lcHTML = loHTTP.HttpGet("http://www.west-wind.com/wconnect/testpage.wwd")

*** Posting XML
loHTTP.nHttpPostMode = 4
lcXML = FILETOSTR("someXmlData.xml")

loHTTP.AddPostKey()  && Clear POST buffer

lcXML = loHTTP.HttpGet("http://www.west-wind.com/wconnect/testxml.wwd")

*** Posting a multi-part form with a File Upload
loHTTP.nHttpPostMode = 2  && Multipart form encoding

loHTTP.AddPostKey()  && Clear existing POST buffer

*** Post a file and a regular form variable
loHttp.AddPostKey("txtFileNotes","test note")

lcHTML = loHTTP.HTTPGet("http://localhost/wconnect/FileUpload.wwd")

See also:

Class wwHttp | wwHTTP::nhttppostmode

© West Wind Technologies, 2020 • Updated: 02/06/19
Comment or report problem with topic