Request API.

Holds request (input) information for the script.


Request has the following parameters:

keys()Lists provided URL parameter names.
get(name)Gets URL parameter with specified string.
has(name)Signals whether URL parameter with specified name exists in string.
body()Returns request body or null for GET requests.
mimeType()Returns body mimetype or null for GET requests.
header(name)Returns the first value of the specified header, if exists
object()Returns parsed request body object for requests with body mime types of "application/x-www-form-urlencoded" or "application/json"


Request has the following properties:

headersJSON object – provides header values
paramsJSON object – provides URL parameters.
userJSON object – provides information about the logged user.
methodString – name of request method (GET or POST).


Let's say we have added following requests parameters:
Db_id = 51bf5ec1975a2d55263801cd, collection = books.
And we added the request body data string: some useful information.
Your URL will look like this:

// Echo service: replies with specified parameters
var responseBody = {},
    requestParams = {},
    paramKeys = Apperyio.request.keys(); // returns array of request parameters ["Db_id", "collection"]
for (var key = 0; key < paramKeys.length; key++) {
    requestParams[paramKeys[key]] = Apperyio.request.get(paramKeys[key]); // returns value of request parameter by its name
responseBody.requestBody = Apperyio.request.body(); // responseBody.requestBody now contains "some useful information"
responseBody.requestParams = requestParams; // responseBody.requestParams now contains object { "DB_id": "51bf5ec1975a2d55263801cd", "collection": "books" }
responseBody.method = method; // responseBody.method now contains string "GET" or "POST".
Apperyio.response.success(responseBody, "application/json");