RESTfm accepts flags and parameters to modify it's input parsing, data processing, and output behaviour.

RESTfm flags and parameters are identified by the prefix 'RFM', and may be supplied in three different locations in this descending order of priority:

  1. As URI query string parameters.
  2. As application/x-www-form-urlencoded or multipart/form-data parameters (only applicable to the HTPT POST method).
  3. As parameters inside the 'info' section of a formatted message (e.g.  JSON, XML, etc.)

The only distinction between RESTfm flags and parameters is that flags have no argument (value). It is ok to assign a value to flags if desired, a good choice would be the number one '1'.

Example message, URI and response:

By utilising the echo service URI, the priority of RFM parameters may be demonstrated.

Echo URI - JSON - RFM Parameter Priority Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
    "info": {
        "RFMparam1": "infoSection",
        "RFMparam2": "infoSection",
        "RFMparam3": "infoSection"
    },
    "data": [
        {
            "Pcode": "9998",
            "Locality": "A New Location 1"
        },
        {
            "Pcode": "9999",
            "Locality": "A New Location 2"
        }
    ]
}
Example JSON RFM parameters priority message.

The above JSON is then URL encoded and passed as the RFMdata parameter in the encoding below.

Note: It is not a requirement to use this double encoding scheme to POST JSON data, it is just used here as a contrived example to demonstrate the three possible locations for RESTfm parameters and their priorities.

Echo URI - embedded JSON - RFM Parameter Priority Example

1
RFMparam1=postBody&RFMparam2=postBody&RFMformat=JSON&RFMdata=%7B%22info%22%3A%7B%22RFMparam1%22%3A%22infoSection%22%2C%22RFMparam2%22%3A%22infoSection%22%2C%22RFMparam3%22%3A%22infoSection%22%7D%2C%22data%22%3A%5B%7B%22Pcode%22%3A%229998%22%2C%22Locality%22%3A%22A%20New%20Location%201%22%7D%2C%7B%22Pcode%22%3A%229999%22%2C%22Locality%22%3A%22A%20New%20Location%202%22%7D%5D%7D
Example embedded JSON RFM parameters priority message.

The final POST URI also contains RESTfm parameters. The response demonstrates the priority of the parameters as determined by RESTfm.

Echo URI - embedded JSON - RFM Parameter Priority Response

http://demo.restfm.com/RESTfm/postcodes/echo.json?RFMparam1=queryString
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
        RESTfm 3.0.0beta/r420 Echo Service
=========================================================
 
------------ Parameters -------------
RFMparam1="queryString"
RFMparam2="postBody"
RFMparam3="infoSection"
RFMformat="JSON"
 
------------ Data -------------------
info:
 
data:
  0:
    Pcode="9998"
    Locality="A New Location 1"
  1:
    Pcode="9999"
    Locality="A New Location 2"
 
 
------------ RESTfm -----------------
request method=POST
response format=json
Example embedded JSON RFM parameters priority response.