SK SKYVVA Documentation

7. REST Adapter

Introduction

Agent REST Adapter is a feature like REST Adapter, but it has more power than the REST Adapter. REST Adapter needs the System to have Public API to call out API, but Agent REST Adapter can callout API with Systems that have Public API and Local API. So it is useful for users who want to keep data in the local System. To use Agent REST Adapter, we need to have an Agent application to store in the local machine meaning that Agent REST Adapter is like a bright to connection Salesforce to the Agent machine and the Agent machine connects to Backend applications. Example: In a Real business scenario, we want to make our data secure, so we need to use a local network zone to install Agent machine and Backend applications such as SAP or Oracle. We do like this because we don't want any systems to access our System, and it is the technique to protect our data from being safe.

The processing of Agent REST Adapter

Here's the picture of the processing of Agent REST Adapter.

In this picture, we can see Salesforce and SKYVVA are in the Internet zone where Agent Machine and Backend applications are in the Local network zone. So when we callout from Salesforce to Backend applications, it will access Agent Machine and Agent Machine send data to Backend applications. The agent is responsible for making connections with the inside enterprise and then connecting with Salesforce (Internet zone). This Adapter is really helpful for users to send data to salesforce to local backend applications.

How to create a REST interface using the Agent REST Adapter?

How to use Agent REST Adapter for callout data from salesforce.  We also learn about how to callout data and get a response message and we will learn how to use fault Interface when the other system has a fault message.

Case 1

Handle API message without Response Interface.

Pre-require

Step 1:  Create or Upload Message Type REST.

–  RESTVersion2_skyvvasolutions__MetaDataProvider__c (5)

Step 2: Create integration and outbound Interface.

Step 3: Configuration Agent Control Board.

How to use the Agent Control Board?

Since the user now completely understand; How to use the Agent Control Board, by hitting the upper link, now we understand the Architect of the Agent Control Board now follows below on Salesforce org. Step4: Create Adapter Agent REST

Fill name, choose Type =Agent Soap, Direction= outbound, choose XML payload, Operation= POST, fill username and password, and choose Adapter_instance.

Step 5: put the adapter into Interface.

Step 6: Callout v3 with Apex code.

skyvvasolutions.CallOutControl c = new skyvvasolutions.CallOutControl(); c.returnJSONComplete=true; c.actionDoIntegrate=true; c.isCreateMessage=true; String[] ids= new String[]{'0011x000015BR30AAG'}; skyvvasolutions.Iservices.invokeCalloutV3('IntegrationName','InterfaceName',ids,'SYNC',c);

Case 2

Handle API Message with Response Interface.

In this case, we just need to create a Response Interface using Soap Message Type. Pre requires

How to Handle API message with Response Interface? In this case, we just need Inbound Interface one more for do response. Because of Case 1, we have configuration some pre-required already. [su_box title="Note" box_color="#2a8af0" title_color="#000000"] Make sure that Message Type Reponses Interface is matching with payload Reponses of other request System or server.[/su_box] Step 1: Create inbound Interface and link Message Type Response

Step 2: Go to Interface Request and put the Response Interface in the field’s response Interface.

Step 3: Callout v3 with Apex code with Request Interface.

skyvvasolutions.CallOutControl c = new skyvvasolutions.CallOutControl(); c.returnJSONComplete=true; c.actionDoIntegrate=true; c.isCreateMessage=true; String[] ids= new String[]{'0011x000015BR30AAG'}; skyvvasolutions.Iservices.invokeCalloutV3('IntegrationName','InterfaceName',ids,'SYNC',c);

Case 3

Handler Over Fault Response.

[su_box title="Note" box_color="#2a8af0" title_color="#000000"]Make sure that Adapter has fault response. [/su_box] Pre requires

Step1: create Inbound Interface as fault Interface.

Step 2: put fault interface in request interface.

Step 3: callout with apex code.

Case 4

Handle multiple different fault messages

[su_box title="Note" box_color="#2a8af0" title_color="#000000"]When we use Multiple different fault messages, we don’t need to put fault Interface in the Request Interface because the field of fault Interface is a priority than related fault Interfaces. If we put Interface in field fault Interface, it will do only with field fault Interface and the related Interface will not do.[/su_box]. Pre-require: 

We have created a Fault Interface system error already so now we need to create two more fault Interfaces. Step1: Go to Integration and create Fault interfaces.

Step2: Put Outbound Interface Name in fault Interface of Every Response Interfaces.

We need to other Response fault Interface like the same way.

Step 3:  Go to Request Interface to see response fault Interfaces related.

Step4: callout with apex code. [su_box title="Note" box_color="#2a8af0" title_color="#000000"] Make sure that API has faults Message.[/su_box]

Case 5

How to use the REST v4 API to push data to Agent?

We have two types of response:

  1. standard response
  2. custom response using the response (outbound) interface to do the mapping
if we want to get data from the response interface then we need to do mapping for the response interface and link it to the request interface. Only data send from the input will return back a response. If we want anything other than the input data then we have to use VLOOKUP formulae in the response mapping.

How to use the Agent Control Board?

Since the user now completely understand; How to use the Agent Control Board, by hitting the upper link, now we understand the Architect of the Agent Control Board now follows below on Salesforce org. –How to create a REST interface using the Agent REST Adapter? Then Go to the adapter tab and create an Inbound adapter. Here we are using the Rest adapter for the Inbound direction.

Step 2: Create Inbound Interface.  To create an Inbound interface refer tutorial from our website: How to create Interface?

Step3: Do mapping and save it.

[su_box title="Note" box_color="#2a8af0" title_color="#000000"]

[/su_box]

Check Result on Message monitoring:-

Open this article in the interactive viewer →