The echo service URI takes submitted data (HTTP body and query string parameters), parses it with RESTfm's format handlers, and returns a readable representation of what it received. The echo service is intended to help development when diagnosing formatting issues. Developers will find the HttpRequester plugin for Firefox an invaluable tool for testing various formats and different HTTP methods with the echo service.

The echo service URI is only available when diagnostics is set to TRUE in RESTfm.ini.php.

GET example

In the following example three query string parameters are submitted to the echo URI. Parameters with the prefix 'RFM' are reserved for use with RESTfm, and appear under 'Parameters' in the response.

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'. So RFMflag=1 would have been acceptable in the example below.

Query string parameters that do not have the prefix 'RFM' are considered to be data for a single record in the form of FieldName = FieldValue pairs. This mechanism for submitting data is limited, but may be used with method override to perform basic CRUD operations, using only HTTP GET.

Echo URI - GET - Flags, Parameters and Data

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
        RESTfm 3.0.0beta/r420 Echo Service
=========================================================
 
------------ Parameters -------------
RFMmethod="POST"
RFMflag=""
RFMparameter="example"
 
------------ Data -------------------
data:
  0:
    someField="someValue"
    otherField="anotherValue"
 
 
------------ RESTfm -----------------
request method=POST
response format=html
Example of RESTfm flags, parameters and record data submitted in a query string.

POST example

In the following example a single record is submitted in JSON format to the echo URI.

Layout URI - JSON - POST Message

1
2
3
4
5
6
7
8
{
    "data": [
        {
            "Pcode": "9999",
            "Locality": "A New Location"
        }
    ]
}
Example JSON format HTTP POST message.

Echo URI - JSON - POST Response

http://demo.restfm.com/RESTfm/postcodes/echo.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        RESTfm 3.0.0beta/r420 Echo Service
=========================================================
 
------------ Parameters -------------
 
------------ Data -------------------
data:
  0:
    Pcode="9999"
    Locality="A New Location"
 
 
------------ RESTfm -----------------
request method=POST
response format=json
Example echo respoonse to JSON format HTTP POST.

POST Bulk Operations example

In the following example multiple records are submitted in JSON format to the echo URI, including two different RFM flags.

Echo URI - JSON - Bulk POST Message with example RFMflag

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
    "data": [
        {
            "Pcode": "9998",
            "Locality": "A New Location 1"
        },
        {
            "Pcode": "9999",
            "Locality": "A New Location 2"
        }
    ],
    "info": {
        "RFMflag2": "1"
    }
}
Example JSON format Bulk HTTP POST message to echo URI.

Echo URI - JSON - Bulk POST Response with example RFM flags

http://demo.restfm.com/RESTfm/postcodes/echo.json?RFMflag1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
        RESTfm 3.0.0beta/r420 Echo Service
=========================================================
 
------------ Parameters -------------
RFMflag2="1"
RFMflag1=""
 
------------ Data -------------------
data:
  0:
    Pcode="9998"
    Locality="A New Location 1"
  1:
    Pcode="9999"
    Locality="A New Location 2"
 
info:
 
 
------------ RESTfm -----------------
request method=POST
response format=json
Example echo response to JSON format Bulk HTTP POST.