RESTfm flags and parameters
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:
- As URI query string parameters.
- As application/x-www-form-urlencoded or multipart/form-data parameters (only applicable to the HTPT POST method).
- 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.
{ "info": { "RFMparam1": "infoSection", "RFMparam2": "infoSection", "RFMparam3": "infoSection" }, "data": [ { "Pcode": "9998", "Locality": "A New Location 1" }, { "Pcode": "9999", "Locality": "A New Location 2" } ] }
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.
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
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