Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

MuleSoft, Salesforce Request

DZone's Guide to

MuleSoft, Salesforce Request

Let's take a look at this tutorial, which explains how to create a simple global HTTP connector to receive requests.

Free Resource

SnapLogic is the leading self-service enterprise-grade integration platform. Download the 2018 GartnerMagic Quadrant for Enterprise iPaaS or play around on the platform, risk free, for 30 days.

MuleSoft has Salesforce connectors that facilitate a request for Salesforce objects.

HTTP Connector:

We are going to create a simple global HTTP connector to receive our requests:

Image title

To make the example simple, we are going to create the following flow:

  • /accounts GET

Image title

HTTP config:

Image title

Salesforce Connector:

Drag and drop the Salesforce connector right after the GET HTTP:

Image title

Select Salesforce Basic Authentication, fill the username, password, and security token with Salesforce credentials. Click validate configurations to check the connection.

Image title

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

Image title

Access http://localhost:8081/accounts from your browser. The result should be:

Image title

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]'

Image title

You also have to edit the HTTP Connector so it can receive "id" as parameter.

/accounts/{id}

Image title

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:

Image title

With SnapLogic’s integration platform you can save millions of dollars, increase integrator productivity by 5X, and reduce integration time to value by 90%. Sign up for our risk-free 30-day trial!

Topics:
mulesoft ,rest ,tutorial ,integration

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}