Response Mappings

Marketo can translate data received by a Webhook from two content types and return these values back to a lead field: JSON and XML. The Marketo Field parameter will always use the SOAP API name of the field. Each Webhook may have an unlimited number of response mappings, which are added and edited by clicking the Edit button in the Response Mappings pane of your Webhook:

Response Mappings are created via a pairing of a Response Attribute, which is a path to the desired property in the XML or JSON document, and the Marketo Field, which specifies the Lead field which will have the value written to it from the Response Attribute.

JSON Mappings

JSON properties are accessed just as you would in Javascript, with dot-notation. To retrieve data from a JSON document, the response type must be set to JSON. Here’s a simple example of a JSON response:

Response

1

2

3

{

"foo":"bar"

}

To access the foo property in a response mapping, we can just use the name of the property since it is in the first level of the JSON object, foo. Here’s what that looks like in Marketo:

Let’s look at a more complicated example with an array:

Response

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

{

"profileId":1234,

"firstName":"Jane",

"lastName":"Doe",

"orders":[

{

"orderId":5678,

"orderDate":"2015-01-01",

"orderProductId":"4982"

},

{

"orderId":5678,

"orderDate":"2014-05-07",

"orderProductId":"4982"

}

]

}

Let’s say that we want to access the orderDate from the first element of the orders array. To access this property, we’ll need to use the following: orders[0].orderDate

XML Mappings

Values van be accessed from individual elements in XML documents. This uses dot notation similar to the JSON mappings. Let’s look at this simple example:

Response

1

2

3

4

<?xml version="1.0"encoding="UTF-8"?>

<example>

<foo>bar</foo>

</example>

In order to access the foo property here, we’ll use the following: example.foo

Note that the example element must first be referenced before accessing foo. In order to access a property, all elements in the hierarchy must be referenced in the mapping. XML documents with arrays are a bit more complicated. Let’s use the following example:

Response

1

2

3

4

5

6

7

8

9

10

11

12

<?xml version="1.0"encoding="UTF-8"?>

<elementList>

<element>

<foo>baz</foo>

</element>

<element>

<foo>bar</foo>

</element>

<element>

<foo>bar</foo>

</element>

</elementList>

Our document consists of a parent array, elementList, with children, element, that contain one property, foo. For the purposes of Marketo response mappings, the array is referenced as “elementList.element”, so the children of the elementList are accessed via “elementList.element[i]”. To get the value of foo from the first child of elementList, we will use this response attribute: elementList.element[0].foo This will return the value “baz” to our designated field. Trying to access properties inside of elements which contain both unique and non-unique element names will result in undefined behavior. Each element must be a single property or an array, the types cannot be intermixed.

Types

When mapping attributes to fields, you will need to ensure that the type in your webhook response is compatible with the target field. For example, if the value in the response is a string, and the selected field is of the type integer, then the value will not be written. More information on Field Types can be found here.

Latest Blog Posts

Keep up with what's new in the developer world

Important Change to Activity Records in Marketo APIs March 1, 2017 Note: This post will be updated to reflect changes made to activity records returned by the API due to migration to new infrastructure.
With the rollout of Marketo’s next-generation Activity Service beginning in September 2017, we will be unable to enforce the uniqueness or presence of the integer “id” field in activities, data value changes, or lead ... Read More >

Spring 2018 Updates June 29, 2018 In the Spring 2018 release we are releasing new REST APIs, and web tracking privacy enhancements. See the full list of updates below.
REST API
Static List CRUD
Allows users to remotely Create, Read, Update, and Delete Static List Records. Enables management of the entire lifecycle of a static list through REST APIs, including populating and maintaining membership. ... Read More >

Winter 2018 Updates March 2, 2018 In the Winter 2018 release, we are releasing a few enhancements to our APIs. See the full list of updates below.
Asset APIs
Activate/Deactivate Trigger Campaigns
We have added the ability to activate and deactivate trigger campaigns, which can simplify the process of automating your program templates. This is achieved by calling two newly added endpoints: Activate Smart Campaign, Deactivate ... Read More >