Skip to main content

Start HTTP Server (script step reference)

By May 1, 2022May 17th, 2022Online Help, Troi Activator Plug-in
Activator Plug-in for FileMaker Pro

Start HTTP Server

Starts the built-in HTTP Server. This web server will trigger a script when data arrives.

SyntaxScript step badge

Start HTTP Server [ Select ; Result (error) ; File name ; Script name ;
                    Password ; Port number ; Switches ]

Options

Select entire contents replaces the entire contents of a field with the result. If not checked the result replaces the currently selected portion of the field
Result (error) an error code
File name the name of the file which contains the script to trigger when a HTTP request arrives
Script name specifies the name of the script to trigger when a HTTP request arrives
Password (optional) a password which the sender needs to add to the HTTP request
Port number (optional) use the specified portnumber, if you leave this empty the default port number of the Activator is used (TCP port 54242)
Switches (optional) Switches modify the behavior of this step

Switches

You can add this switch:

-AllowAnyPostedText allow any text to be posted to the url "/posttext.html"

Returned Result

Data type returned

Error code

Result

The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:

0 no error
$$-50 paramErr there was an error with a parameter

Other errors may be returned.

Originated in

Activator Plug-in 4.5

Compatibility

FileMaker Pro 16 to 19

Considerations

Only HTTP requests which are posted to the right web page will trigger the script. Other requests (for example for the index.html page) do not trigger a script but a default webpage will be returned to the remote client.

Remote clients can trigger a script with a URL like this:

http://www.example.com:54242/triggerscript.html?yourText=someText

See the ‘Set HTTP Response’ script step and the HTTPResponse.fmp12 example file for more detailed information on how to sent a custom response.
When the URL contains a password parameter, the password will be removed from the result returned by

Actr_GetEventInfo ("-GetURL" ; $EeventID)

This script step also lets the Activator Plug-in act as an Image Upload Server. See the UploadData.fmp12 example file for more detailed information. You can also send text only to the plug-in.

To upload text posted to the url “/posttext.html” you need to wrap it in tags like this:


  <TROI_TEXT_UTF8>
  your UTF8 formatted text
  </TROI_TEXT_UTF8>

New for v8.0: If you want to allow allow any text to be uploaded to the upload server add the switch “-AllowAnyPostedText” when starting the server.

On macOS the plug-in will make the HTTP server known via Bonjour as “Troi Activator Upload Server”, allowing for easy discovery.

Example

Start HTTP Server [ Select ; Result ; "Upload.fmp12" ; 
				"HTTP_TriggerScript" ; "secret" ]

This command starts the HTTP Server. When (image) data comes in, it will trigger the script “HTTP_TriggerScript” in file “Upload.fmp12”. Note that this example is somewhat simplified, normally you should not use a hard coded filename like in the above example.

Example 2

Add the following script steps:

Set Variable [ $password ; "secret" ) ]
Start HTTP Server [ Select ; Result ; Get ( FileName ) ; 
				"HTTP_TriggerScript" ; $password ; 12345 ]

This command will start the HTTP Server, with the HTTP Server listening on port 12345. Users can now send images or text data from other computers or for example an iPhone or iPad.

Used in example files

UploadData.fmp12
HTTPResponse.fmp12

Related script stepsScript step badge

Set HTTP Response
Stop HTTP Server

Related functionsFunction badge

Actr_GetEventInfo
Actr_StartHTTPServer

Related topics

Activator Plug-in online help (overview)


Online Help Page for Activator Plug-in for 16 to 19 –> Start HTTP Server (actrp7621) 2022-0517 10:56:21