Webhook Payload Templates, Tokens and the Describe REST API

Anonymous
Not applicable

Webhook Payload Templates, Tokens and the Describe REST API

We currently have an integration that enhances lead data through a webhook. It makes use of the Payload Template to pass the information needed to our application which works beautifully.  The payload template string is built by our application for our users to paste into the webhook definition based on their field selections. This is currently done using the describeMObject SOAP API to get the field definitions. 

We are now trying to switch over to using the REST API and, therefore, need to obtain the fields using the Describe endpoint. However, the Describe endpoint does not return all the information that we require. This is preventing us from building the field tokens for the payload template.  The specific piece that we require is the sourceObject value (Lead, Company, etc.) which is combined with the displayName to build the token.  

Consider the tokens for Address and Company: 
{{Lead.Address}} and {{Company.Company Name}}

Using the describeMObject SOAP API call we get the following response for Address and Company:

<MObjFieldMetadata>
  <name>Address</name>
  <description />
  <displayName>Address</displayName>
  <sourceObject>Lead</sourceObject>

  <dataType>text</dataType>
  <size>2000</size>
  <isReadonly>false</isReadonly>
  <isUpdateBlocked>false</isUpdateBlocked>
  <isName />
  <isPrimaryKey>false</isPrimaryKey>
  <isCustom>false</isCustom>
  <isDynamic>true</isDynamic>
  <dynamicFieldRef>leadAttributeList</dynamicFieldRef>
  <updatedAt>2014-03-25T18:07:35-04:00</updatedAt>
</MObjFieldMetadata>

<MObjFieldMetadata>
  <name>Company</name>
  <description />
  <displayName>Company Name</displayName>
  <sourceObject>Company</sourceObject>

  <dataType>string</dataType>
  <size>255</size>
  <isReadonly>false</isReadonly>
  <isUpdateBlocked>false</isUpdateBlocked>
  <isName />
  <isPrimaryKey>false</isPrimaryKey>
  <isCustom>false</isCustom>
  <isDynamic>true</isDynamic>
  <dynamicFieldRef>leadAttributeList</dynamicFieldRef>
  <updatedAt>2014-03-25T18:07:35-04:00</updatedAt>
</MObjFieldMetadata>

Using the Describe endpoint from the REST API we get the following response for Address and Company:

{
    "id": 60,
    "displayName": "Address",
    "dataType": "text",
    "length": 0,
    "rest": {
        "name": "address",
        "readOnly": false
    },
    "soap": {
        "name": "Address",
        "readOnly": false
    }
}

{
    "id": 2,
    "displayName": "Company Name",
    "dataType": "string",
    "length": 255,
    "rest": {
        "name": "company",
        "readOnly": false
    },
    "soap": {
        "name": "Company",
        "readOnly": false
    }
}

My question is: How can I get the sourceObject value using the REST API? 
 
Tags (1)
2 REPLIES 2
Anonymous
Not applicable

Re: Webhook Payload Templates, Tokens and the Describe REST API

I do not think you can get it thought a REST API.  However, you might be able to get throught the export of the Field names (under Admin/Field Managment clicke the "Export Field names") to get an XLS file with mapping of Soap/Rest field names to display names.

If you are not adding lots of fields, you can get the names once and then hard code them.  But kind of a pain if you are frequently adding new fields.....

 

Anonymous
Not applicable

Re: Webhook Payload Templates, Tokens and the Describe REST API

Thank you for the suggestion. Unfortunately, this is not an option. Our integration is used by multiple customers all with different Marketo installs. The field list is built dynamically in our application from the user's marketo instance.