Vlocity Facts #51 || Using DataMapper Extract as Rest API
In Previous posts we have seen how to Using Integration Procedure as Rest API.
In this post we will see how to Invoke DataMapper as REST API.
Data Mapper Extract Invocation Using GET
To retrieve data from Salesforce using a REST call, you need to issue a GET request that triggers a Data Mapper Extract. You can specify the data to be retrieved either by providing the object ID or by defining one or more matching parameters. The response will return the data in JSON format, as defined by the Data Mapper Extract's output configuration.
In this post we will see how to Invoke DataMapper as REST API.
Data Mapper Extract Invocation Using GET
To retrieve data from Salesforce using a REST call, you need to issue a GET request that triggers a Data Mapper Extract. You can specify the data to be retrieved either by providing the object ID or by defining one or more matching parameters. The response will return the data in JSON format, as defined by the Data Mapper Extract's output configuration.
1. Use an ID to Retrieve Data
First we will design a DataMapper which accepts recordId as a Input parameter.
Refer this link for creating new DataMapper Extract
First we will design a DataMapper which accepts recordId as a Input parameter.
Refer this link for creating new DataMapper Extract
To retrieve Salesforce data by specifying the Id, issue a GET request that invokes a Data Mapper Extract, using a URL formatted as follows:
- myOrgNamespace - Namespace prefix
- DataMappername - Name of the DataMapper Extract
- In Id we need to pass the record Id - don't change the Parameter of "Id' to any other parameter
Example: We will create a sample Data Mapper Extract to get "Account and Account related Contacts"
While configuring the Data Mapper - filter value should be Id because the value what you're passing it will be in Id
From Workbench we will call this DataMapper Extract by using below syntax
URL: /services/apexrest/omnistudio/v2/DataRaptor/DRMExtractAccountContactDetails/0015i000004rK1TAAU
In Id pass the accountId.
2. Use Parameters to Retrieve Data
We can pass multiple parameters to retrieve data from Salesforce by using DataMapper Extract by issuing a get request.
While configuring the Data Mapper - filter value should be Id because the value what you're passing it will be in Id
From Workbench we will call this DataMapper Extract by using below syntax
URL: /services/apexrest/omnistudio/v2/DataRaptor/DRMExtractAccountContactDetails/0015i000004rK1TAAU
In Id pass the accountId.
2. Use Parameters to Retrieve Data
We can pass multiple parameters to retrieve data from Salesforce by using DataMapper Extract by issuing a get request.
- myOrgNamespace - Namespace prefix
- DataMappername - Name of the DataMapper Extract
- In Param1 and Param2 we will mention the key name which is used as a filter in DataMapper and in Val1, Val2 we will pass the details.
Will use same DataMapper Extract by adding more filters.
Comments
Post a Comment