Exposing An API And Getting Data From Salesforce Based On Request Schema
In this blog, We will see how to expose an API in Workato and based on the request schema how will we get the data from Salesforce.
What is an API?
API stands for Application Programming Interface. In the context of APIs, the word Application refers to any software with a distinct function. Interface can be thought of as a contract of service between two applications. This contract defines how the two communicate with each other using requests and responses.
Step 1: Now, log onto the Workato platform (https://app.workato.com/)with the required credentials i.e. Email Address and Password.

Step 2: Now Click on Project.

Step 3: Now Give a Project Name and Description and click on Create Project.

Step 4: Now you can see you project is created with the name you have given.
Now Click on Create and the click on Recipe.

Step 5: Give your Recipe a name and Select build an API point and click on Start Building.

Step 6: Go to Setup and then go to Request Schema and Click on add fields manually.

Step 7: Fill in the Name field, choose the Datatype, select the optional field, then Click on Add Field.

Step 8: Go to Responses and Click on Add Response

Step 9: Give the Response Name and choose Http Status code response.

Step 10: Go to Response Schema and Click on add fields manually.

Step 11: Fill in the Name field, choose the Datatype, select the optional field, then Click on Add Field.

Step 12: Click on Action in an app.

Step 13: Choose App as Salesforce and click on Salesforce.

Step 14: Select records using SOQL query WHERE clause.

Step 15: Click on New Connection to created connection with Salesforce.

Step 16: Give your Connection a name and choose Auth Type as OAuth 2.0 and the scroll down and click on connect.

Step 17: A pop-up will appear where you have to give your Salesforce User Credentials and click on Login your Connection will be established.

Step 18: Your Connection is established. Now, we are in Setup and here search for which object you want to get data from Salesforce.

Step 19: Now we will write just the WHERE clause query on the basis of which we will get data from Salesforce and MAP the field with Request Parameter and put it inside single quotes as shown in the picture.

Step 20: Now we will scroll down and go to Fields to retrieve and will choose the fields which we want to retrieve and click on Save.

Step 21: Now again click on Action in App

Step 22: Now search for API by Workato and click on it.

Step 23: Now Just Click on Response and Choose the Response name you created while creating an response schema in Step 9.

Step 24: Now MAP the fields from Step 2 as shown in the picture.

Step 25: You can see all fields are mapped.
Now click on save.

Step 26: Now your interface is ready click on exit.

Step 27: You will be moved to this page. On this page click on Start Recipe.

Step 28: Go the to left bar and click on the API platform.

Step 29: Click on API Collection.

Step 30: Click on New Collection.

Step 31: Give your endpoint a name, choose your recipe, and give an endpoint path, you can also scroll down to change the HTTP verb and then click on Add Endpoint.

Step 32: Your API Collection is created and active your collection by clicking on the toggle button and then click on your collection.
Here our API is exposed.

Step 33: By clicking on your collection you will be moved to this page
Here, We will consume our API using WORKATO
Now click on Try it out.

Step 34: Give an account name for which you want to get the data from Salesforce and click on execute.

Step 35: After clicking on Execute scroll down and you can see the HTTP status code and Response from the API.
