API Services allow you to create a custom protocol to interface with an External Application in order to share data securely.

For example, if your Fonteva application needs to update an external database, you would configure an API Service to handle the attributes of where the data is going, the Authentication protocols used, and other settings.

To add a new API Service from the Spark Admin Dashboard: 

  1. [Select]  .

  2. [Select] . 

       

The API Service modal displays. This modal has three tabs. 

    • Create 

    • Connect 

    • Deploy 

3. [Enter] the information indicated:  

    • API Service Key  The name of the API Service in the code. This object can be a maximum of 8 characters. 

    • Display name  The displayed name of the API Service in Spark User Interface.

    • Description - A brief description of what the API Service does.

    • Endpoint - Your base endpoint URL for all API calls.

    • Authentication Service - This field stores the global parameter that sends the VendorAuthenticationClass from Fonteva to the External Application. If the External Application uses a custom authentication parameter, please use one of the following:

      • buildTokenUrl  - This builds a redirect to the External Application that allows the user to get the Initial Token. In the UI, the user will see the login page of the selected External Application. This method returns a page reference.

      • buildAuthorizationCodeUrl - This provides the specific URL to get the Access Token from the External Application. This method takes a map value and returns a string.
      • extractAccessToken - This tells Fonteva to extract the Access Token from the External Application. Each app returns the token differently. It's important that Fonteva extracts the token correctly. This method takes a map value and returns a string.
    • Auth Type - Select one of the following from the menu: 

      • Basic

      • OAuth1A

      • OAuth2

      • None

 

4. [Click] .


The Connect tab workflow is determined by the Authentication Type you select. For more information on individual workflows, [click] Authentication Types.

  

On the Deploy tab: 


 5. [Enter] the Icon Image URL.

 6. [Click] the Is Enabled select box to enable the API Service.

 7. [Click] . 

  

Required fields are marked with an asterisk (*) 

Logging API Callouts

API Services can be configured to automatically log every callout and the response in the service log. To start this, you must enable Debug Mode in API Services.

Scenario Part 1: API Service

For more information on the terms below, see Api.Service.

Framework.Api.Service service = new Framework.Api.Service();
service.name = 'Twitter';
service.endpoint ='https://api.twitter.com';
service.isEnabled = true ;
service.debugMode = true ;
service.apexClass = 'Framework.VendorAuthenticationService';
service.namespace = 'N/A';
service.authType = Framework.VendorAuthenticationService.AuthType.OAuth1A;
 

Framework.Config.push(service);
CODE