Post URL (script step reference)

Troi URL Plug-in > Script steps reference > Post URL
Troi URL Plug-in for FileMaker Pro

Post URL

Sends data to the server, using the POST method, and returns the result as raw data.

SyntaxScript step badge

Post URL [ Select ; Result ; Switches ; URL ; Post data ]

Options

Select entire contentsreplaces the entire contents of a field with the result. If not checked the result replaces the currently selected portion of the field
Resultthe raw data returned (or an error code)
Switchesthis determines the behavior of the plug-in
URLthe url of the server
Post datathe data to be sent with the POST method

Switches

Switches can be one or more of these:

-NoDialogdon’t display a progress dialog
-TimeoutTicks=xspecify the connect timeout time in x ticks (1/60th of a second)
-ReturnHeaderinclude the header in the returned text (at the beginning)
-ReturnDataAfterErrorreturn the error code followed by the data
-Portnumber=yspecify the port number to use
-NotEncodedsend the post data without any normal encoding for “www-form-urlencoded”
-DontAutoRedirectthe plug-in will not go to a redirected page but return the original page
-AllowAnyRootCertificate(for HTTPS) allow root certificates from unrecognized certification authorities. Note that this is less secure
-ExtraCRLFafterDataan extra CRLF (carriage return and line feed) character is added at the end of the Post data
-AlwaysSendUserPasswordwill directly send the username + password, even when this might not be necessary
-DontTryWithUserPassworddon’t send username + password when the web server requests authorization
-Encoding=ISO_8859_1encodes the data in ISO-8859-1 (Latin-1)
-Encoding=UTF8encodes the data in UTF-8, and also the resulting data
-DontDetectEncodingdisable automatic UTF-8 encoding detection, instead keep the native encoding

Returned Result

Data type returned

Text

Result

If successful it returns the data of the URL. If unsuccessful it returns an error code starting with $$ and the error code. Returned error codes can be:

$$-1user cancelled
$$-4230the connection timed out
$$-3242this protocol is not supported (use only http and https)
$$-30776authentication error, you need to supply a correct user name and password
$$-92servername part of the url is too long
$$-2110path part of the url is too long

Other errors may be returned, specifically errors in the range 300 to 599, which are HTTP Status Codes.

Originated in

Troi URL Plug-in 5.0

Compatibility

FileMaker Pro 16

Considerations

Secure connections (HTTPS) using SSL are also supported on Windows and Mac OS.
If you don’t specify a timeout, a default timeout of 15 seconds is used.
See the user guide section “How to make sense of a web form”, to determine what you must send to make the form work.

On Mac OS a progress dialog is displayed. On this platform you can also cancel a long operation with an ESC or a Command-Period.

The length of the URL is limited, by both the plug-in and receiving servers. A lot of web servers don’t support URLs longer than 2048 characters. Note that the plug-in has higher limits of 32867 characters for the URL. The 5th parameter “Post data” has a limit of about a half GB of characters.
On Mac OS you might need to set cookies to get the desired result. See the TURL_SetCookies function.
See also TURL_SetCustomHeader for special headers, that may be needed, for example in a form.

The plug-in can automatically detect UTF-8 encoded web pages (and encode them correctly). This is enabled by default, and is determined by looking for the meta and charset tag in the HTML result of the Post URL script step. For an XML result the “encoding=utf-8” tag will also be detected.

Example

Post URL [ Select ; Result ; "-unused" ; "http://www.idninc.com/cgi-bin/sherlock.cgi" ; 
                            "name=troi" ]

This will send the form data “name=troi” for the Sherlock form “cgi-bin/sherlock.cgi” to the server www.idninc.com and return the result. This will return something similar to:

    <HTML>
    <HEAD><TITLE>COMPANY SEARCH</TITLE></HEAD>
    <body><CENTER><!--BANNER_START--><A HREF="http://www.BestSiteFirst.com">
    <IMG SRC="http://www.idninc.com/images/banner.gif" border=0></A>
    <!--BANNER_END-->
    ...
    <!--SEARCH_RESULTS_START-->
    <P> <!--RELEVANCE-->100<!--END_RELEVANCE-->
    % <A HREF="http://www.troi.com">Troi Automatisering: For FileMaker Pro plug-ins</A>
    <UL>Check out the latest FileMaker Pro Plug-ins from Troi Automatisering.  </UL></P>
    ...
    <!--SEARCH_RESULTS_END-->
    </UL></BODY>
    </HTML>

Example 2

We assume that in your FileMaker file the following fields are defined:

theURL		       	Text
gTimeOutTime         	Global, number

theURL should contain the URL, for example “http://www.filemaker.com”. In a script add the following script steps:

Set Field [ formData ; "name=troi&number=123456" ]
Post URL [ Select ; resultText ; "-TimeoutTicks=" & gTimeOutTime ; theURL ; formData ]

This will post the form data to the URL specified and return the result as raw HTML data. If the server does not react the script step will timeout after gTimeOutTime ticks and an error code of “$$-4230” will be returned.

Related script stepsScript step badge

Delete URL
Get URL
Put URL

Related functionFunction badge

TURL_Post

Online Help Page for Troi URL Plug-in for 12 to 16 –> Post URL (urlp7401) 2017-0626 14:09:37