Using REST Services from Alpha Anywhere

Description

Overview of REST Client Api Support in Alpha Anywhere.

Name
Description
Accessing Rest API Services from Server-side Xbasic Code
How to access Rest API Services using Xbasic.

 REST Client Genie

UX Components can make calls to third-party REST service providers, like Google, Twitter or Dropbox, or the server, on behalf of the client.

The REST Genie is available in all the Client JavaScript Action Scripting events on a UX.

The REST Genie defines how you will bind parameters to a REST call to controls and variables on a UX Component.

There are predefined 'REST' service definitions, along with Predefined 'Provider' definitions, but it is possible for users to add their own service definitions.

If the REST service you are using requires credentials, which most will, you will need to set up a 'Named Resource' for the Provider that the REST Genie expects.

It is important to note that the code that the REST genie generates does not embed any credentials, Credentials are always looked up using the 'Named Resource', which makes it possible to easily Deploy an application to a Web Site with different Credentials (A common pattern, since a development machine will often run with Test Credentials).

 Named Resource

The Named Resource, which is stored in the 'Project Settings' and can be overridden in the 'Publish Profile' defines credentials for a specific Provider.

The Named Resource can use pre-defined System Providers (like Google and Twitter), or can use Providers defined by the developer using a Provider Definition.

 Provider

A 'Provider' definition describes how a provider is implemented.

For example, it will describe if the provider is oAuth 1.0, oAuth 2.0 or uses API Keys or basic authentication.

OAuth provider definitions will include the endpoints used to login, get an access token, etc.

API Provider Definitions will include the fields expected, for example - a messaging provider may include an account id, a secret, and a phone number, I which case the API Provider would define the definition as requiring these three fields.

There are built in providers, but users may create their own providers as JSON files in a folder under the Web Project called 'oAuthProviders' for the oAuth 1.0 and 2.0 definitions, and a folder called 'ApiCredentials' for API definitions.

 REST API Definition

A REST API Definition defines the endpoints for actions, the data returned and consumed by the rest service, and how the endpoints bind to the Providers.

As with the Providers, there are built in 'REST API' Definitions, but users can add their own in the new 'REST References' Panel of the Web Control Panel.

How REST Client Components Are Related