FileMaker Pro/Go - Insert From URL with httppost

FileMaker 13 introduced the 'httppost' protocol for use with the 'Insert From URL' script step. This new protocol allows FileMaker to act as a RESTfm client where data may be submitted to RESTfm and the response stored in a field.

Due to limitations in the design of the 'Insert From URL' script step, some characters cannot be submitted (specifically '&' and '='). This page describes a workaround by applying additional encoding to allow all possible characters to be submitted in a POST. RESTfm is informed of this additional encoding through the use of the RFMfixFM02 flag.

Note: This no longer applies to FileMaker 16 and later where the Insert From URL step allows proper data passing and encoding.

Note: Under the hood, 'httppost' POSTs data as application/x-www-form-urlencoded format. It is not possible to submit a raw message body, the data must be passed in as 'fieldName=value' pairs separated by '&'.

Note 2: Except where additional pre-encoding is noted below, no 'URL encoding' should be performed on the string passed to 'Insert From URL', this is handled automatically for you by FileMaker (which is why it is impossible to submit data containing '&' and '=' characters).

Encoding rules

  1. For each fieldName and value to be submitted:
    • Replace all occurrences of '%' with '%25' (This step must be done first).
    • Replace all occurrences of '=' with '%3D' and '&' with '%26'.
    • Join each fieldName and value with '='
  2. Join each 'fieldName=value' pair with '&'.
  3. Add '&RFMfixFM02=1' to end of string.
  4. Join string to httppost:// URL with '?'.

Basic POST example

This example submits a single record consisting of fieldName/value pairs to RESTfm, where fieldName may not begin with the prefix 'RFM' (this limitation is described in the section about POSTing data in application/x-www-form-urlencoded format).

Note: Only the encoding rules listed above are used, no additional 'URL encoding' is performed. Spaces and new-lines/line-breaks are maintained all of the way through to the final string.

Raw data to submit:

field 1 field 2
a b c Percent: %
Equals: =
Ampersand: &

Encoding step 1:

For each fieldName and value to be submitted:
  • Replace all occurrences of '%' with '%25' (This step must be done first).
  • Replace all occurrences of '=' with '%3D' and '&' with '%26'.
  • Join each fieldName and value with '='
  • This can be done in FileMaker with a single substitite function : Substitute ( text ; [ "%" ; "%25" ] ; [ "&" ; "%26" ] ; [ "=" ; "%3D" ] )
field 1=a b c field 2=Percent: %25
Equals: %3D
Ampersand: %26

Encoding step 2:

Join each 'fieldName=value' pair with '&'.field 1=a b c&field 2=Percent: %25 Equals: %3D Ampersand: %26

Encoding step 3:

Add '&RFMfixFM02=1' to end of string.

field 1=a b c&field 2=Percent: %25 Equals: %3D Ampersand: %26&RFMfixFM02=1

Encoding step 4:

Join string to httppost:// URL with '?'.

Note: Please allow for line wrapping in output here. New-lines/line-breaks should appear in the same location as step 3 above.

httppost://user:pass@example.com/RESTfm/mydb/layout/mylay.simple?field 1=a b c&field 2=Percent: %25 Equals: %3D Ampersand: %26&RFMfixFM02=1

The string is now ready for use with the 'Insert from URL' script step.

Embedded 'simple' format POST example

This example is considerably more complex but allows for the submission of bulk data with no restriction on fieldNames. This is done by embedding another document into an RFMdata field, as described in the section about Embedding data in other formats. We will embed a simple format document in this example.

Raw data to submit:

Pcode Comments
9998 line 1
line 2
9999 line 1
line 2

Records converted to simple format CREATE message:

1 2 3 data Pcode="9998"&Comments="line 1¶line 2" Pcode="9999"&Comments="line 1¶line 2"
Example bulk simple format CREATE message.

Embed simple format message into RFMdata field:

Must include RFMformat field to describe embedded format in RFMdata field.
RFMformat RFMdata
simple data
Pcode="9998"&Comments="line 1¶line 2"
Pcode="9999"&Comments="line 1¶line 2"

Encoding step 1:

For each fieldName and value to be submitted:
  • Replace all occurrences of '%' with '%25' (This step must be done first).
  • Replace all occurrences of '=' with '%3D' and '&' with '%26'.
  • Join each fieldName and value with '='
RFMformat=simple RFMdata=data
Pcode%3D"9998"%26Comments%3D"line 1¶line 2"
Pcode%3D"9999"%26Comments%3D"line 1¶line 2"

Encoding step 2:

Join each 'fieldName=value' pair with '&'.

RFMformat=simple&RFMdata=data Pcode%3D"9998"%26Comments%3D"line 1¶line 2" Pcode%3D"9999"%26Comments%3D"line 1¶line 2"

Encoding step 3:

Add '&RFMfixFM02=1' to end of string.

RFMformat=simple&RFMdata=data Pcode%3D"9998"%26Comments%3D"line 1¶line 2" Pcode%3D"9999"%26Comments%3D"line 1¶line 2"&RFMfixFM02=1

Encoding step 4:

Join string to httppost:// URL with '?'.

Note: Please allow for line wrapping in output here. New-lines/line-breaks should appear in the same location as step 3 above.

httppost://user:pass@demo.restfm.com/RESTfm/postcodes/bulk/brief postcodes.simple?RFMformat=simple&RFMdata=data Pcode%3D"9998"%26Comments%3D"line 1¶line 2" Pcode%3D"9999"%26Comments%3D"line 1¶line 2"&RFMfixFM02=1

The string is now ready for use with the 'Insert from URL' script step.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us