Error getting tags :
error 404Error getting tags :
error 404 post | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
post
Basics
Expander triangle
Type
Command
Syntax

post data to URL destinationURL

Introduced
1.0
Environment
Desktop, Web and Server
Platform Support
MacOS,Mac OS X,Windows,Linux
Security
Network
Summary
Sends data to a web server using the POST action of HTTP.
Examples

post myData to URL "http://www.example.net/indications.cgi"
post field "Return Values" to URL field "Current Page"

Additional Comments
Expander triangle

Use the post command to submit data to a web server.

Parameters:

The data is any string.

The destinationURL is the URL where the data is to be sent.

Comments:

Data you send should be encoded using the URLEncode function.

The value the web server returns is placed in the it variable. If an error occurs, the result function is set to the error message.

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 postcommand is a blocking operation: that is, the handler pauses until Revolution 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.

Important! If a blocking operation involving a URL (using the putcommand to upload a URL, the postcommand, the delete URLcommand, or a statement that gets an ftp or httpURL) is going on, no other blockingURL operation can start until the previous one is finished. If you attempt to use a URL in an expression, or put data into a URL, while another blockingURL operation is in progress, the result is set to "Error Previous request not completed".

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 URLEncodefunction 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. To ensure that the command works in a standalone application, you must include this custom library when you create your standalone. In the Inclusions section of the Standalone Application Settings window, make sure "Internet Library" is selected in the list of script libraries.

Note: When included in a standalone application, the Internet library is implemented as a hidden group and made available when the group receives its first openBackground message. During the first part of the applicati startup process, before this message is sent, the post command is not yet available. This may affect attempts to use this command in startup, preOpenStack, openStack, or preOpenCard hand in the main stack. Once the application has finished starting up, the library is available and the post command can be used in any handler.

User Comments
Expander triangle
User thumbnail
Devin Asay
StarStarStarStarStar
Apr 13, 2009
Web servers scripts that accept POST data expect it in the following format:
name1=value1&name2=value2&name3=value3
When you construct your data string in Revolution make sure that it comes out formatted that way. For example:


put "term" & "=" & urlEncode(fld "termToTranslate") & "&" & \
"language" & "=" & the hilitedButtonName of group "langGrp" into tMyPostData

User thumbnail
Devin Asay
StarStarStarStarStar
Nov 3, 2010
I added the previous note before I knew about the libURLFormData function. This function formats a string of data to the proper format for GET and POST requests.