request object

request object

Updated: June 16, 2015

In a Table operations, used to execute the requested table operation and determine the response to the client. In a Custom API, exposes the request object functionality implemented by the Express.js library.

When used in a script registered to a table operation, this object contains the following members:

The following functions are used in table operation scripts:


Syntax Returns Description



Executes the default behavior for the operation.



Executes the operation with success or error handlers supplied as options. For more information, see Overriding success and error.


Syntax Returns Description



Writes the default response.



Writes a response with the specified error object.

request.respond(statusCode, body)


Writes a custom response with the provided HTTP status code and message body.

The following property is supported in table operations.


Name Returns Description


JSON object

Returns a collection of parameters supplied to the request URI as query parameters.

When used in a custom API export, this object contains the following members:

The following function is used in a custom API:


Syntax Returns Description


JSON object

Returns a JSON representation of the named header-value from the HTTP request headers sent in a custom API request. For more information, see Content types and headers.

The following properties of the Express.js request object are commonly used in a custom API.


Name Returns Description


JSON object

Returns a collection of all the message headers, as a JSON object. Individual headers are obtained by calling the header function. For more information, see Content types and headers.


JSON object

Used to access any custom query parameters provided in the request.


service object

The returned service object provides access to these mobile service-specific objects: push, tables, and mssql.


user object

Returns the user object, which contains information about the client sending the request.

For a complete list of all properties available on the request object, see the express.js library documentation.

Table operations:

Microsoft Azure Mobile Services enables you to register JavaScript code to be executed by the service when an insert, update, delete, or query operation occurs against a specific table. These scripts provide the ability to inject business logic into table operation, stop an operation from taking place, change values supplied to the operation or change the results. For more information, see How to: Register scripts on the server.

The request object is always the third argument passed to a registered script function. You must call either execute or respond in your script to make sure that the client receives a response. If you do not do this, the operation times-out.

Custom API:

The request object is passed as the first argument to the function that defines an exported HTTP method in a custom API. This version of the request object uses the express.js library to provide additional functionality to your scripts.

© 2015 Microsoft