Sends data to a web server using the POST action of http.
# Metadata
Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 1.0 Security: network
# Syntax
post data to URL destinationURL
# Params
- data : Any text that evaluates to a string. - destinationURL : The URL where the data is to be sent.
# Examples
post myData to URL "http://www.example.net/indications.cgi"
post field "Return Values" to URL field "Current Page"
post tData to URL tMyUrl
# Description
Use the post command to submit data to a web server.
The HTTP header sent with the POST request can be changed using either the HTTPHeaders property or the libURLSetCustomHTTPHeaders command. By default, the "Content-Type" header line is set to "application/x-www-form-urlencoded".
>*Note:* Sending data with the post command is a blocking > operation: that is, the handler pauses until LiveCode is finished > sending the data. Since contacting a server may take some time, due > to network lag, URL operations may take long enough to be noticeable > to the user.
To send a username and password with the post command, use the standard syntax for including this information in a URL. For example, to access http://www.example.com/ with the username "me" and the password "pass", use the following statement :
post someData to URL "http://me:pass@www.example.com/"
>*Important:* If your user name or password contains any of the > characters ":", "@", "/", ".", or "|", use the URLEncode function > to safely encode the user name or password before putting them into > the URL. The following example constructs a URL for a user whose > password contains the "@" character:
put "name" into userName put "jdoe@example.com" into userPassword put "http://" & userName & ":" & URLEncode(userPassword) \ & "@www.example.net/index.html" into fileURLToGet get URL fileURLToGet
>*Important:* The post command is part of the > Internet library on desktop platforms. To ensure that the command > works in a desktop standalone application, you must include this > LiveCode custom library when you create your > standalone application. In the Inclusions pane of the > Standalone Application Settings window, make sure the "Internet" > script library is selected.
>*Cross-platform note:* On iOS and Android, the post command > is implemented in the engine. Therefore the Internet library is not > needed to ensure the command works in a mobile > standalone application. If included, the Internet library > implementation will be used instead of the engine implementation. > *Note:* The Android and iOS engines do not support 'libUrl' but do > allow you to use post in the background. When specifying URLs for > Android or iOS, you must use the appropriate form that conforms to > [RFC 1738](https://tools.ietf.org/html/rfc1738). Ensure that you > URLEncode any username and password fields appropriately for FTP > URLs.
# Tags
# See
- **property:** httpHeaders, HTTPProxy - **message:** urlProgress - **library:** Internet library - **keyword:** URL, ftp, http - **control structure:** function - **function:** result, URLStatus, URLEncode, libURLFormData, URLDecode, libURLMultipartFormAddPart, libURLMultipartFormData - **command:** post, write to socket, delete URL, read from socket, put, libURLSetExpect100, libURLSetLogField, open socket, libURLSetCustomHTTPHeaders - **glossary:** variable, command, LiveCode custom library, property, standalone application, blocking, web server, command, expression, syntax, server, upload, statement, handler, Standalone Application Settings