SALES: 1-800-867-1380

request object

Updated: August 25, 2013

In a table operation script, used to execute the requested table operation and determine the response to the client. In a custom API script, 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:

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 Overriding success and error.

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.

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.

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

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.

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

service object

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

user

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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft