Bu içerik dilinizde bulunmamaktadır ancak İngilizce sürümüne buradan bakabilirsiniz.

Custom API


Updated: June 16, 2015

Microsoft Azure Mobile Services enables you to define one or more custom APIs in your mobile service. A custom API is an endpoint in your mobile service that is accessed by one or more of the standard HTTP methods: GET, POST, PUT, PATCH, DELETE. In a JavaScript backend mobile service, custom API scripts are created and edited in the portal or uploaded using the service’s Git repository.

For a .NET backend mobile service, custom APIs are defined as a class in the Visual Studio project that derives from ApiController and implements a Services property that returns an ApiServices object. There is no support for .NET backend custom APIs in the Management Portal.

In a JavaScript backend, a separate function export can be defined for each HTTP method supported by the custom API, all in a single script file. The registered script is invoked when a request to the custom API using the given method is received. Custom API enables you to expose server functionality that does not map to an insert, update, delete, or read operation or as a scheduled job. A custom API is called by sending an HTTP request of a supported method, to a URI in the following general format.


To register a JavaScript custom API, click the Create button, select the permissions for HTTP methods used to call the API, then click OK. The following default “Hello World” implementation for the POST method is generated and displayed in the script editor.

exports.post = function(request, response) {
    // Use "request.service" to access features of your mobile service, e.g.:
    //   var tables = request.service.tables;
    //   var push = request.service.push;

    response.send(200, "Hello World");

For an example of how to create and call a custom API, see Call a custom API from the client (Windows Store C# / Windows Store JavaScript / Windows Phone / iOS / Android).

In a JavaScript backend, a custom API is essentially a Node.js module that exposes one or more public functions that map canonically to HTTP methods. These functions are exposed by using the exports object, such as exports.post in the previous example that handles POST requests. Each exported custom API function is passed a request object and response object. These objects are implemented by the express.js library, and they expose the APIs of the express.js library.

In a custom API, you can access server script global objects (push, tables, and mssql) from the service object on the request. As with table operations, you can set the same permissions on each HTTP method supported by your custom API. For authenticated clients, you can also perform user-specific authorizations based on the user.userId value of the supplied request object.


When a server script has not been registered to an HTTP method on a custom API, a request to that method returns a 405 error code.

For more information about custom API, see Mobile Services server script reference.