http POSTData property
Return to Introduction  Previous page  Next page
Applies to
WinHTTP component.  

Declaration
property POSTData: String;  

Description
The POSTData property specifies any optional data to send with the HTTP request. The optional data can be the resource or information being posted to the server.  
 
tip The POSTData property is generally used to POST some data to the CGI programs. For example, you would like to emulate submission of some online form. Set the POSTData accordingly to the fields of HTML form. The format is following:  
FieldName1=Value1&FieldName2=Value2&VieldNameN=ValueN  
(Separate entries with "&" character.) Then just point the URL property to the CGI script (specified as <form action=URL> tag in HTML format) and call Read method to submit the form.  

Example: (requesting data from the CGI script (at Torry.net) via POST method)
procedure TForm1.ReadBtnClick(Sender: TObject);  
begin  
  WinHTTP1.URL := 'http://www.torry.net/quicksearch.php';  
  WinHTTP1.POSTData := 'String=HTTP&Exact=Yes&Title=No';  
  WinHTTP1.Read;  
end;  
 
procedure TForm1.WinHTTP1Done(Sender: TObject; ContentType: string; FileSize: Integer; Stream: TStream);  
begin  
  // Receiving content from Stream  
end;  

iiinfo Remarks
1.When you trying to POST data to the CGI program specifying the POSTData property, make sure that RequestMethod has set to rmAutoDetect or rmPOST;  
2.The WinHTTP component unable to post data to the CGI program when user working offline (even if user connected to the Internet). In this case, when you call the Read method, the OnHostUnreachable event occurs. Posting to the CGI programs requires active Internet connection.  

See also
RequestMethod property and Read method.