Using the Marketo REST API with Boomi: Getting and Deleting Leads from a Static List

February 6, 2015 | by

In part 1 of this series, I discussed how it was possible to start using the REST API through Boomi with the Boomi HTTP connector, specifically getting the authentication token needed to access the REST API, and storing it in a Process Variable.

Next up, we’ll begin making calls into Marketo, and in this installment, I’ll show you how you can both Get Multiple Leads By List ID and Remove Leads from List. Pay particular attention to the removal of leads from a list because there is a very “lightly documented” and subtle aspect of Boomi at work there that I’ll expand on when we get there.

In out NEXT installment we’ll expand on this functionality to start doing interesting things like getting Lead activity, but that’s a blog for another day.

boomi1

For this installment we’ll be looking at the second and third highlighted areas.

As a review, I’ve included the JSON responses we’ll be needing below. Recall that to create a JSON profile in Boomi, all you need to do is create a profile component of type JSON, and click “import” and select the file. Boomi does the rest, extrapolating things like if there should be multiple IDs allowed.

Example JSON for Get Multiple Leads By List ID

Example JSON for Remove Leads from List Request

Example JSON for Remove Leads from List Response

Step 1: The Get Multiple Leads by List ID

Drop another connector (Get) into your process, using the same connection as defined in the previous article.

Create a new operation called “Get Multiple Leads by List ID” (I’m a stickler for consistency) It’s attributes are as follows
– Request Profile: None (this one uses the request URL)
– Response Profile Type: jSON
– Response Profile: Create a new profile based on the Get Multiple Leads by List ID Response above.

Note that you can change it so that it returns the fields you want, not just the ones listed. Its important to remember that the JSON response profile should really match the list of fields you’re asking for from the REST API, and you should request only the fields you need. In the Process Properties object, we defined a property called “fields” which is a comma separated list of the fields you want REST to return.. and that’s the list that has to match the profile.
Content Type: text/plain (this is just a URL request)
HTTP Method: GET (you look this up in the REST API docs, its always listed)
Resource Path (add 5)
rest/v1/list/
listID (replacement variable)
/leads.json?access_token=
access_token (replacement variable)
&fields=
fields (replacement variable)

booomi2

Then in the parameters tab on the connector, you can enter the variable values, all of which we previously populated into the process properties. In the next section I’ll talk about how you can avoid populating these manually

boomi3

Im going to skip the part of the process where I map the response for Get Multiple Leads by List Id into a flat file profile and stick it on an FTP server because that’s straightforward Boomi functionality.

Step 2: Delete Leads from a List
So this one is interesting, one of my coworkers, Ken Niwa taught me this next technique and it’s pretty cool and based on a Boomi article titled “How to Build a POST Request for a RESTful Application”, shown below.

boomi4

boomi5

…but first things first. In the process, coming out of the “Get Multiple Leads by List Id” we have the Get Multiple Leads by List Id Response shape, and we need to map that into the “Remove Leads from List Request” that mapping is fairly simple, just mapping the id we got from the leads in the original list into the id list we’re passing into the delete jSON.

boomi6

Next, drop another Connector with an action of “Send”, using the same Connection

Create a new operation called “Remove Leads from List Request”.. whose attributes are
Request Profile: jSON
Content Type: application/json
Request Profile: [JSON Profile] Remove Leads from List Request (created from the above file)

Response Profile Type: jSON
Response Profile: [JSON Profile] Remove Leads From List Response (created from the above file)
Content Type: application/json

HTTP Method: DELETE
Resource Path (add 4)
rest/v1/lists/
listID (replacement variable)
/leads.json?access_token=
access_token (replacement variable)

Here’s the interesting thing about this connector. We’re NOT going to explicitly add the parameters in the connector tab. Instead, as the article states, we’ll create dynamic document properties that have the same names as the replacement variables. In this case, those variables listID and access_token. When you do this, the jSON shape will flow into the REST call and the parameters will appear in their proper place on the URL. We can’t do this with the previous call because it’s a GET not a POST.

boomi7

So at this point you’ve seen a GET and a POST REST API call and you can start to see the pattern for making these REST calls. In the next installment we’ll start looking at Lead Activity export through the REST API, which is a bit more involved.