External Services can be invoked from Flows.
1. Go to https://app.swaggerhub.com/home and Sign Up for Trial.
2. Create an API using “Create New API” option in Swagger.
3. Enter the API details and click “Create API Swagger” button.
4. Use the following specification to create the API.
openapi: 3.0.0
info:
version: '1'
title: ''
description: Employee Search API
paths:
/employee:
get:
tags:
- EmployeeAPI
summary: API to search employees
operationId: searchEmployee
description: |
You can search for an employee in the system
parameters:
- in: query
name: employeeNo
description: Employee Number to search in the system
required: true
schema:
type: string
responses:
'200':
description: search results matching criteria
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Employee'
'400':
description: bad input parameter
components:
schemas:
Employee:
type: object
required:
- empNo
- employeeName
- employeeAge
- employeeJoiningDate
properties:
empNo:
type: string
format: uuid
example: emp-01
employeeName:
type: string
example: Test Name
employeeAge:
type: number
example: 19
employeeJoiningDate:
type: string
format: date
example: '2015-01-01'
servers:
# Added by API Auto Mocking Plugin
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/<YOUR_USERNAME>/Employee/1
5. Publish the API.
6. Export the API.
7. Create a Salesforce External Credential.
8. Create a Salesforce Named Credential.
9. Create a Salesforce Permission Set.
10. In the Permission Set, give access to User External Credentials object.
11. Assign the Permission to the users who will be accessing the External Service.
12. In the External Credential, click New button on the Permission Set Mappings section.
13. Assign the Permission Set to the External Credential.
14. Create an External Service using New External Service button in Salesforce.
15. Use From API Specification.
16. Use Complete JSON as the Service Schema and use the JSON exported from the Swagger.
17. Select the searchEmployee operation.
18. Use the searchEmployee action in the Flow to test.
Output: