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

The State of API Integration 2018: Get Cloud Elements’ report for the most comprehensive breakdown of the API integration industry’s past, present, and future.

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

Your API is not enough. Learn why (and how) leading SaaS providers are turning their products into platforms with API integration in the ebook, Build Platforms, Not Products from Cloud Elements.

Topics:
mulesoft ,rest ,tutorial ,integration

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}