DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Configuring a Shopify MuleSoft Connector
  • Handle HL7 MLLP Messages With Mule 4
  • SharePoint Integration With MuleSoft
  • Configuring Amazon S3 Using Mulesoft

Trending

  • The Self-Hosting Math Changed While We Were Still Arguing About Sovereignty
  • Guess the Speed: Building a Family Internet Speed Guessing Game
  • Why Spark Executors Leave Cores Idle on YARN: A Packing Model for Executor Sizing
  • Member Spotlight: Raghava Dittakavi

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. MuleSoft, Salesforce POST

MuleSoft, Salesforce POST

Take a look at this tutorial for more information on how to create a simple global HTTP connector to receive requests in Salesforce.

By 
Ugo Augusto Gustavo Guazelli
·
Aug. 07, 18 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
10.7K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

HTTP Config:

MuleSoft has Salesforce connectors that facilitate CRUD operations for Salesforce objects. If you need to get data from Salesforce, take a look at MuleSoft, Salesforce Request.

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:

  •     /contacts POST  

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 out the username, password, and security tokens with Salesforce credentials.

  • Click validate configurations to check the connection.

Image title

Salesforce Create:

Going back to the Salesforce connector, select Create as Operation.

We are going to create a Contact so select it as sObject type.

Keep the sObject Field Mappings as default. From Expression #[payload]

Image title

Drag and drop a transformer connector between HTTP and Salesforce. Doing that, you can make use of the data sense to help you to make the transformations.

Image title

Image title

We are going to use the following payload to create a contact:

{
"last_name": "Obama",
"first_name": "Barack",
    "cel": "555 6987",
    "personal_email": "[email protected]"
}

The MuleSoft Transformer should look like this:

%dw 1.0
%output application/java
---
[{
LastName: payload.last_name,
FirstName: payload.first_name,
Phone: payload.cel,
Email: payload.personal_email
}]

Image title

NOTE: Pay special attention to %output, as it should be application/java

Add another transformer connector after the Salesforce connector. It will be responsible for transforming the resulted Salesforce message into JSON format.

Image title

The transform message should look like this:

%dw 1.0
%output application/json
---
{
    id: payload[0].id,
    success: payload[0].success
}

Image title

Creating a Contact

Start the Mule project from Postman, make a post request, and pass the contact JSON as a parameter:

{
"last_name": "Obama",
"first_name": "Barak",
    "cel": "555 5555",
    "personal_email": "[email protected]"
}

Image title

The JSON response should indicate if the contact was properly created.

Opening Salesforce, we can find our created Contact (Barak Obama).

Image title

MuleSoft POST (HTTP) Connector (mathematics)

Opinions expressed by DZone contributors are their own.

Related

  • Configuring a Shopify MuleSoft Connector
  • Handle HL7 MLLP Messages With Mule 4
  • SharePoint Integration With MuleSoft
  • Configuring Amazon S3 Using Mulesoft

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook