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-Mapping

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.

Note: Keys for properties must consist of alphanumeric characters, dash (-), underscore(_), colon (:), and whitespace in order to be accessed via Marketo response mappings

JSON Mappings

JSON properties are accessed with dot-notation, and array notation.  Array notation in Marketo will not accept strings as input, and will only accept integers. To retrieve data from a JSON document, the response type must be set to JSON. Here’s a simple example of a JSON response:

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:

json-resp

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

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:

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:

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.