Skip to content


$.request object represents the client HTTP request currently being processed.


Sample Usage

// defined a hardcoded users array for the example
let users = [
    {id: '1', name: 'John'},
    {id: '2', name: 'Ben'},
    {id: '3', name: 'George'}

function getUser(id) {
    // retrieve user operation by id
    return users.find(function(user) {
        return === id;

function createUser(data) {
    // create user operation which will update the users array only for the scope of the current request call as the users are hardcoded
    users.push({id:, name:});

function deleteUser(id) {
    // delete user operation which will remove a user only for the current scope of the request as the users are hardcoded
    users = users.filter(function(user) {
        return !== id

function allUsers() {
    // retrieve all users operation
    return users;

// get id query param 
const id = $.request.parameters.get("id");

// check the type of the request
switch($.request.method) {
    case $.net.http.PUT:
        if($.request.contentType === "application/json") {

            $.response.setBody(`created user [${ JSON.stringify($.request.body.asString()) }]`);
        } else {
                "error": "Unsupported content type."
    case $.net.http.GET:
        if (id) {
            let user = getUser(id);

            $.response.setBody(JSON.stringify({ user: user }));
        } else {

            let users = allUsers();

            $.response.setBody(JSON.stringify({ users: users }));

    case $.net.http.DELETE:
        if (id) {

            $.response.setBody(`deleted user with id [${ id }]`);
        } else {
                "error": `Parameter id is missing`

            "error": `Unsupported method [${ $.request.method }]` 


Name Description Type
body The body of the request. $.web.Body
contentType The content type of the entity. string
cookies The cookies associated with the entity. $.web.TupelList
entities The sub-entities of the entity. $.web.EntityList
headers The headers of the entity. $.web.TupelList
language Language of the request in IETF (BCP 47) format. string
method The HTTP method of the incoming HTTP request. $.net.http
parameters The parameters of the entity. $.web.TupelList
path The URL path specified in the request. string
queryPath The URL query path specified in the request. string


Function Description Returns
setBody(body) Sets the body of the entity. -