+

Search Tips | Advanced Search

For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.


Client access to adapters

Mobile clients can access both Javaâ„¢ and JavaScript adapters from the /adapters endpoint on the server.

The URL pattern for accessing the /adapters endpoint is as follows:

For example, assuming that http://mfp-server-host/project is the IBM MobileFirstâ„¢ Platform Foundation project URL, and the project contains one Java adapter named adapter1 and the adapter has a resource with path /res1, then /res1 is accessible from the following URL:

Note: Using the /adapters endpoint is the recommended way to access IBM MobileFirst Platform Foundation adapters. This endpoint supports both JavaScript and Java adapters and is protected by an OAuth security mechanism.


Accessing adapters from a mobile client

IBM MobileFirst Platform Foundation provides a client API for accessing OAuth protected resources such as adapters. If you choose to use MobileFirst client for that purpose, it will automatically handle security for you. The following examples demonstrate how to use the client API to access an adapter resource:


RESTful access to Java adapters

You call an existing Java adapter over HTTP via REST URLs.

The URL pattern is as follows:

For example:

Java adapters support all REST features, so we can use all HTTP request methods, headers, query parameters, and more.


RESTful access to JavaScript adapters

You call existing JavaScript adapter procedures over HTTP via REST URLs.

The URL pattern is as follows:

For example:

Both the GET and POST methods can be used to call the adapter procedure. The procedure arguments are passed as the value of a parameter called params. This parameter is a query parameter for GET requests and a form parameter for POST requests. The value must be a JSON array of parameters that are provided in order.

Note: For successful invocations, the status code of the HTTP response is set to 200 (OK). The response body contains the JSON output that resulted from the invocation of the JavaScript adapter. If an error occurred during adapter invocation, the status code is set to 500 (Internal Server Error).

Parent topic: Develop the server side of a MobileFirst application