MuleSoft, Salesforce Request
Let's take a look at this tutorial, which explains how to create a simple global HTTP connector to receive requests.
Join the DZone community and get the full member experience.Join For Free
MuleSoft has Salesforce connectors that facilitate a request for Salesforce objects.
We are going to create a simple global HTTP connector to receive our requests:
To make the example simple, we are going to create the following flow:
Drag and drop the Salesforce connector right after the GET HTTP:
Select Salesforce Basic Authentication, fill the username, password, and security token with Salesforce credentials. Click validate configurations to check the connection.
Salesforce Query ALL:
Going back to the Salesforce connector, select Query as Operation. We are going to use the following query to get some values from Account Object:
Note: You can use Query Builder to help you to build the query.
SELECT AccountNumber, BillingCity, BillingCountry, Id, Name, Phone FROM Account
Access http://localhost:8081/accounts from your browser. The result should be:
Salesforce Query by ID:
Now, let's go even further and come back to the Salesforce connector and edit the query:
SELECT AccountNumber, BillingCity, BillingCountry, Id, Name, Phone FROM Account WHERE Id = '#[message.inboundProperties.'http.uri.params'.id]'
You also have to edit the HTTP Connector so it can receive "id" as parameter.
In doing so, you can try to request an Account passing id as parameter. From the browser, access http://localhost:1983/accounts/0016A00000ADPL4QAP
Note: You should be using an existing ID, otherwise, you will not get anything. You can use any ID from the first request result.
The result should be:
Opinions expressed by DZone contributors are their own.