request object
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.
Table operations
When used in a script registered to a table operation, this object contains the following members:
Functions
The following functions are used in table operation scripts:
execute
Syntax |
Returns |
Description |
---|---|---|
request.execute() |
undefined |
Executes the default behavior for the operation. |
request.execute(options) |
undefined |
Executes the operation with success or error handlers supplied as options. For more information, see 90f9c218-7b5b-497a-9495-38586a0b910f#overriding. |
respond
Syntax |
Returns |
Description |
---|---|---|
request.respond() |
undefined |
Writes the default response. |
request.respond(err) |
undefined |
Writes a response with the specified error object. |
request.respond(statusCode, body) |
undefined |
Writes a custom response with the provided HTTP status code and message body. |
Properties
The following property is supported in table operations.
Name |
Returns |
Description |
---|---|---|
parameters |
JSON object |
Returns a collection of parameters supplied to the request URI as query parameters. |
Custom API
When used in a custom API export, this object contains the following members:
Functions
The following function is used in a custom API:
header
Syntax |
Returns |
Description |
---|---|---|
request.header('header-value') |
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. |
Properties
The following properties of the Express.js request object are commonly used in a custom API.
Name |
Returns |
Description |
---|---|---|
headers |
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. |
query |
JSON object |
Used to access any custom query parameters provided in the request. |
service |
The returned service object provides access to these mobile service-specific objects: push, tables, and mssql. |
|
user |
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.
Remarks
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.
See Also
Custom API
Mobile Services JavaScript (Node.js) backend library